diff options
| author | 2026-02-20 21:19:47 +0800 | |
|---|---|---|
| committer | 2026-02-20 21:34:42 +0800 | |
| commit | 05e07f6c6aca1662c33359f41c66e6f9b6eb935a (patch) | |
| tree | 6928a76783b2230a010c36d53b8da48ff24d611f /internal/testgit/repo_commit_tree.go | |
| parent | oid: Add ObjectID (diff) | |
| signature | No signature | |
testgit: Add test harnesses
Diffstat (limited to 'internal/testgit/repo_commit_tree.go')
| -rw-r--r-- | internal/testgit/repo_commit_tree.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/testgit/repo_commit_tree.go b/internal/testgit/repo_commit_tree.go new file mode 100644 index 00000000..b5f2f587 --- /dev/null +++ b/internal/testgit/repo_commit_tree.go @@ -0,0 +1,23 @@ +package testgit + +import ( + "testing" + + "codeberg.org/lindenii/furgit/oid" +) + +// CommitTree creates a commit from a tree and message, optionally with parents. +func (repo *TestRepo) CommitTree(tb testing.TB, tree oid.ObjectID, message string, parents ...oid.ObjectID) oid.ObjectID { + tb.Helper() + args := []string{"commit-tree", tree.String()} + for _, p := range parents { + args = append(args, "-p", p.String()) + } + args = append(args, "-m", message) + hex := repo.Run(tb, args...) + id, err := oid.ParseHex(repo.algo, hex) + if err != nil { + tb.Fatalf("parse commit-tree output %q: %v", hex, err) + } + return id +} |
