Fast implementation of Git in pure Go
at master 29 lines 703 B view raw
1package testgit 2 3import ( 4 "testing" 5 6 "codeberg.org/lindenii/furgit/objectid" 7) 8 9// CommitTree creates a commit from a tree and message, optionally with parents. 10func (testRepo *TestRepo) CommitTree(tb testing.TB, tree objectid.ObjectID, message string, parents ...objectid.ObjectID) objectid.ObjectID { 11 tb.Helper() 12 13 args := make([]string, 0, 2+2*len(parents)+2) 14 15 args = append(args, "commit-tree", tree.String()) 16 for _, p := range parents { 17 args = append(args, "-p", p.String()) 18 } 19 20 args = append(args, "-m", message) 21 hex := testRepo.Run(tb, args...) 22 23 id, err := objectid.ParseHex(testRepo.algo, hex) 24 if err != nil { 25 tb.Fatalf("parse commit-tree output %q: %v", hex, err) 26 } 27 28 return id 29}