blob: 97a86be5603e6b41c7c44529ee7f5ef7c5d4b0be (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
}
|