func getSignatureFromLastCommit(repo *git.Repository) (*git.Signature, error) { master, err := repo.LookupReference(MasterRef) if err != nil { return nil, err } defer master.Free() objId := master.Target() c, err := repo.LookupCommit(objId) if err != nil { return nil, err } defer c.Free() return c.Committer(), nil }
func gitCommit(repo *git.Repository, message string, tree *git.Tree, authorName, authorEmail string) error { commitSignature := &git.Signature{ Name: "shortbread", Email: "*****@*****.**", When: time.Now(), } if authorName == "" { authorName = commitSignature.Name } if authorEmail == "" { authorEmail = commitSignature.Email } signature := &git.Signature{ Name: authorName, Email: authorEmail, When: time.Now(), } parentCommit := make([]*git.Commit, 0) master, err := repo.LookupReference(MasterRef) if err != nil { _, err = repo.CreateCommit(MasterRef, signature, commitSignature, message, tree, parentCommit...) return err } defer master.Free() objId := master.Target() c, err := repo.LookupCommit(objId) if err != nil { return err } parentCommit = append(parentCommit, c) _, err = repo.CreateCommit(MasterRef, signature, commitSignature, message, tree, parentCommit...) return err }