ugit @main -
refs -
log -
-
https://git.jolheiser.com/ugit.git
Signature
-----BEGIN SSH SIGNATURE-----
U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY
oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
AAAAQJd3iQ3fsrerBWzlJJoRWaR6C+usbNwdWnMti+7AXKBpTX0MeVR/FZgA5GE4tPFCZW
g6bEVBguqX2Y/Dml6yWwM=
-----END SSH SIGNATURE-----
diff --git a/go.mod b/go.mod
index f45ce70ff5c7efe470b6fded5ac5ef5a926033ec..1f0c033f3103579b1efe9a683f5e84be74a94d49 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,7 @@
toolchain go1.23.3
require (
+ github.com/alecthomas/assert/v2 v2.11.0
github.com/alecthomas/chroma/v2 v2.15.0
github.com/charmbracelet/ssh v0.0.0-20241211182756-4fe22b0f1b7c
github.com/charmbracelet/wish v1.4.4
@@ -25,6 +26,7 @@ require (
dario.cat/mergo v1.0.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.1.4 // indirect
+ github.com/alecthomas/repr v0.4.0 // indirect
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/bubbletea v1.2.4 // indirect
@@ -46,6 +48,7 @@ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
+ github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
diff --git a/go.mod.sri b/go.mod.sri
index 2e15174fa899f860c46cd1552fb70c3be79d1f4f..c3162dad9d9a679756089019fb1cfdb640bf24fa 100644
--- a/go.mod.sri
+++ b/go.mod.sri
@@ -1 +1 @@
-sha256-+pv4dv79+/WUMiPmlK9eebS3NR6aT8q/Cw+MZ5BWoxg=
\ No newline at end of file
+sha256-L87PnM43gHrDcsRr3wnkB4e1Th2S0LsSwkXuebAFH44=
\ No newline at end of file
diff --git a/internal/git/git_test.go b/internal/git/git_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..fd5ee80a7b76409c4f99be8a55c4ee942af54876
--- /dev/null
+++ b/internal/git/git_test.go
@@ -0,0 +1,45 @@
+package git_test
+
+import (
+ "path/filepath"
+ "testing"
+
+ "github.com/alecthomas/assert/v2"
+ "go.jolheiser.com/ugit/internal/git"
+)
+
+func TestEnsureRepo(t *testing.T) {
+ tmp := t.TempDir()
+
+ ok, err := git.PathExists(filepath.Join(tmp, "test"))
+ assert.False(t, ok, "repo should not exist yet")
+ assert.NoError(t, err, "PathExists should not error when repo doesn't exist")
+
+ err = git.EnsureRepo(tmp, "test")
+ assert.NoError(t, err, "repo should be created")
+
+ ok, err = git.PathExists(filepath.Join(tmp, "test"))
+ assert.True(t, ok, "repo should exist")
+ assert.NoError(t, err, "EnsureRepo should not error when path exists")
+
+ err = git.EnsureRepo(tmp, "test")
+ assert.NoError(t, err, "repo should already exist")
+}
+
+func TestRepo(t *testing.T) {
+ tmp := t.TempDir()
+ err := git.EnsureRepo(tmp, "test.git")
+ assert.NoError(t, err, "should create repo")
+
+ repo, err := git.NewRepo(tmp, "test")
+ assert.NoError(t, err, "should init new repo")
+ assert.True(t, repo.Meta.Private, "repo should default to private")
+
+ repo.Meta.Private = false
+ err = repo.SaveMeta()
+ assert.NoError(t, err, "should save repo meta")
+
+ repo, err = git.NewRepo(tmp, "test")
+ assert.NoError(t, err, "should not error when getting existing repo")
+ assert.False(t, repo.Meta.Private, "repo should be public after saving meta")
+}