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_hash_object.go | |
| parent | oid: Add ObjectID (diff) | |
testgit: Add test harnesses
Diffstat (limited to 'internal/testgit/repo_hash_object.go')
| -rw-r--r-- | internal/testgit/repo_hash_object.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/testgit/repo_hash_object.go b/internal/testgit/repo_hash_object.go new file mode 100644 index 00000000..97a86be5 --- /dev/null +++ b/internal/testgit/repo_hash_object.go @@ -0,0 +1,18 @@ +package testgit + +import ( + "testing" + + "codeberg.org/lindenii/furgit/oid" +) + +// HashObject hashes and writes an object and returns its object ID. +func (repo *TestRepo) HashObject(tb testing.TB, objType string, body []byte) oid.ObjectID { + tb.Helper() + hex := repo.RunInput(tb, body, "hash-object", "-t", objType, "-w", "--stdin") + id, err := oid.ParseHex(repo.algo, hex) + if err != nil { + tb.Fatalf("parse git hash-object output %q: %v", hex, err) + } + return id +} |
