diff options
| author | 2026-03-06 08:05:51 +0800 | |
|---|---|---|
| committer | 2026-03-06 10:00:35 +0800 | |
| commit | e15054a4f93fc54806e84aa7036e60168e78e823 (patch) | |
| tree | b576dcb1d3368324e7ca73ca0fe79dd8865c5524 /internal/testgit/repo_rev_list.go | |
| parent | internal/intconv: Add Uint32ToUint8 (diff) | |
| signature | No signature | |
format/commitgraph: Add initial commit-graph support
Diffstat (limited to 'internal/testgit/repo_rev_list.go')
| -rw-r--r-- | internal/testgit/repo_rev_list.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/testgit/repo_rev_list.go b/internal/testgit/repo_rev_list.go new file mode 100644 index 00000000..d3adf5a0 --- /dev/null +++ b/internal/testgit/repo_rev_list.go @@ -0,0 +1,37 @@ +package testgit + +import ( + "strings" + "testing" + + "codeberg.org/lindenii/furgit/objectid" +) + +// RevList runs "git rev-list" with args and parses one object ID per line. +func (testRepo *TestRepo) RevList(tb testing.TB, args ...string) []objectid.ObjectID { + tb.Helper() + + cmdArgs := make([]string, 0, len(args)+1) + cmdArgs = append(cmdArgs, "rev-list") + cmdArgs = append(cmdArgs, args...) + out := testRepo.Run(tb, cmdArgs...) + + lines := strings.Split(strings.TrimSpace(out), "\n") + + outIDs := make([]objectid.ObjectID, 0, len(lines)) + for _, line := range lines { + line = strings.TrimSpace(line) + if line == "" { + continue + } + + id, err := objectid.ParseHex(testRepo.algo, line) + if err != nil { + tb.Fatalf("parse rev-list oid %q: %v", line, err) + } + + outIDs = append(outIDs, id) + } + + return outIDs +} |
