aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-21 11:25:41 +0800
committerGravatar Runxi Yu2026-02-21 11:25:41 +0800
commit54baeb0ec3778b63a8088d0f5ef4ac9aa90d077d (patch)
tree1f0eb0891ebac06fa18485e54b12b17be4ab9b32 /internal
parentobjectstore/packed: Add initial pack reading support (diff)
signatureNo signature
testgit: Add ref-related functions
Diffstat (limited to 'internal')
-rw-r--r--internal/testgit/repo_refs.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/testgit/repo_refs.go b/internal/testgit/repo_refs.go
new file mode 100644
index 00000000..258d2787
--- /dev/null
+++ b/internal/testgit/repo_refs.go
@@ -0,0 +1,38 @@
+package testgit
+
+import (
+ "strings"
+ "testing"
+
+ "codeberg.org/lindenii/furgit/objectid"
+)
+
+// UpdateRef updates a ref to point at id.
+func (testRepo *TestRepo) UpdateRef(tb testing.TB, name string, id objectid.ObjectID) {
+ tb.Helper()
+ testRepo.Run(tb, "update-ref", name, id.String())
+}
+
+// SymbolicRef sets a symbolic reference target.
+func (testRepo *TestRepo) SymbolicRef(tb testing.TB, name, target string) {
+ tb.Helper()
+ testRepo.Run(tb, "symbolic-ref", name, target)
+}
+
+// PackRefs runs git pack-refs with args.
+func (testRepo *TestRepo) PackRefs(tb testing.TB, args ...string) {
+ tb.Helper()
+ cmd := append([]string{"pack-refs"}, args...)
+ testRepo.Run(tb, cmd...)
+}
+
+// ShowRef returns lines from git show-ref output.
+func (testRepo *TestRepo) ShowRef(tb testing.TB, args ...string) []string {
+ tb.Helper()
+ cmd := append([]string{"show-ref"}, args...)
+ out := testRepo.Run(tb, cmd...)
+ if strings.TrimSpace(out) == "" {
+ return nil
+ }
+ return strings.Split(strings.TrimSpace(out), "\n")
+}