From 5893630f4aecf5365f953a161d5133f128374aff Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 7 Jun 2026 07:05:48 +0000 Subject: internal/testgit: Add helpers to prepare for commit testing --- internal/testgit/object.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'internal/testgit/object.go') 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 +} -- cgit v1.3.1-10-gc9f91