aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/object.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-07 07:05:48 +0000
committerGravatar Runxi Yu2026-06-07 07:05:48 +0000
commit5893630f4aecf5365f953a161d5133f128374aff (patch)
treeb26a52ad56406b8ef088cd24634f64ed599fea21 /internal/testgit/object.go
parentUnify rules around errors.go or not (diff)
signatureNo signature
internal/testgit: Add helpers to prepare for commit testing
Diffstat (limited to 'internal/testgit/object.go')
-rw-r--r--internal/testgit/object.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/testgit/object.go b/internal/testgit/object.go
index a5f7163b..cbdfce76 100644
--- a/internal/testgit/object.go
+++ b/internal/testgit/object.go
@@ -27,3 +27,16 @@ func (repo *Repo) HashObject(tb testing.TB, ty typ.Type, body io.Reader) (id.Obj
return objectID, nil
}
+
+// CatFile returns the raw content of an object
+// (without the "type size\x00" header).
+func (repo *Repo) CatFile(tb testing.TB, ty typ.Type, oid id.ObjectID) ([]byte, error) {
+ tb.Helper()
+
+ stdout, err := repo.Run(tb, nil, "git", "cat-file", ty.Name(), oid.String())
+ if err != nil {
+ return nil, fmt.Errorf("cat-file: %w", err)
+ }
+
+ return stdout, nil
+}