ref: 5d84c4a2716c9dec5f9fcfcce4ca7f8a65cad3ff
dir: /internal/testgit/repo_commit_tree.go/
package testgit
import (
"testing"
"codeberg.org/lindenii/furgit/objectid"
)
// CommitTree creates a commit from a tree and message, optionally with parents.
func (repo *TestRepo) CommitTree(tb testing.TB, tree objectid.ObjectID, message string, parents ...objectid.ObjectID) objectid.ObjectID {
tb.Helper()
args := []string{"commit-tree", tree.String()}
for _, p := range parents {
args = append(args, "-p", p.String())
}
args = append(args, "-m", message)
hex := repo.Run(tb, args...)
id, err := objectid.ParseHex(repo.algo, hex)
if err != nil {
tb.Fatalf("parse commit-tree output %q: %v", hex, err)
}
return id
}