MCPcopy
hub / github.com/redspread/spread / Commit

Method Commit

pkg/project/commit.go:11–30  ·  view source on GitHub ↗
(refname string, author, committer Person, message string)

Source from the content-addressed store, hash-verified

9)
10
11func (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
32func (p *Project) writeIndex() (*git.Tree, error) {
33 index, err := p.repo.Index()

Callers

nothing calls this directly

Calls 3

headCommitMethod · 0.95
writeIndexMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected