(refname string, author, committer Person, message string)
| 9 | ) |
| 10 | |
| 11 | func (p *Project) Commit(refname string, author, committer Person, message string) (commitOid string, err error) { |
| 12 | var parents []*git.Commit |
| 13 | if head, err := p.headCommit(); err == nil { |
| 14 | parents = append(parents, head) |
| 15 | } |
| 16 | |
| 17 | gitAuthor, gitCommitter := git.Signature(author), git.Signature(committer) |
| 18 | |
| 19 | commitTree, err := p.writeIndex() |
| 20 | if err != nil { |
| 21 | return "", err |
| 22 | } |
| 23 | |
| 24 | commit, err := p.repo.CreateCommit(refname, &gitAuthor, &gitCommitter, message, commitTree, parents...) |
| 25 | if err != nil { |
| 26 | return "", fmt.Errorf("failed to create commit: %v", err) |
| 27 | } |
| 28 | |
| 29 | return commit.String(), nil |
| 30 | } |
| 31 | |
| 32 | func (p *Project) writeIndex() (*git.Tree, error) { |
| 33 | index, err := p.repo.Index() |
nothing calls this directly
no test coverage detected