From 2c79eaae593f5669f5f596337f5ac98492cc1127 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 6 Jun 2026 17:45:29 +0000 Subject: testgit: Add config support --- internal/testgit/object.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'internal/testgit/object.go') diff --git a/internal/testgit/object.go b/internal/testgit/object.go index 6f1a2dd8..a5f7163b 100644 --- a/internal/testgit/object.go +++ b/internal/testgit/object.go @@ -1,7 +1,9 @@ package testgit import ( + "fmt" "io" + "strings" "testing" "lindenii.org/go/furgit/object/id" @@ -10,18 +12,18 @@ import ( // HashObject hashes and writes an object, // and returns its object ID. -func (repo *Repo) HashObject(tb testing.TB, ty typ.Type, body io.Reader) id.ObjectID { +func (repo *Repo) HashObject(tb testing.TB, ty typ.Type, body io.Reader) (id.ObjectID, error) { tb.Helper() stdout, err := repo.Run(tb, body, "git", "hash-object", "-t", ty.Name(), "-w", "--stdin", "--literally") if err != nil { - tb.Fatalf("hash-object: %v", err) + return id.ObjectID{}, fmt.Errorf("hash-object: %w", err) } - id, err := repo.objectFormat.FromString(string(stdout)) + objectID, err := repo.objectFormat.FromString(strings.TrimSuffix(string(stdout), "\n")) if err != nil { - tb.Fatalf("parse git hash-object output %q: %v", string(stdout), err) + return id.ObjectID{}, fmt.Errorf("parse git hash-object output %q: %w", string(stdout), err) } - return id + return objectID, nil } -- cgit v1.3.1-10-gc9f91