diff options
| author | 2026-06-07 07:05:48 +0000 | |
|---|---|---|
| committer | 2026-06-07 07:05:48 +0000 | |
| commit | 5893630f4aecf5365f953a161d5133f128374aff (patch) | |
| tree | b26a52ad56406b8ef088cd24634f64ed599fea21 /internal/testgit/object.go | |
| parent | Unify rules around errors.go or not (diff) | |
| signature | No signature | |
internal/testgit: Add helpers to prepare for commit testing
Diffstat (limited to 'internal/testgit/object.go')
| -rw-r--r-- | internal/testgit/object.go | 13 |
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 +} |
