MCPcopy Index your code
hub / github.com/google/git-appraise / CreateCommit

Method CreateCommit

repository/git.go:630–655  ·  view source on GitHub ↗

CreateCommit creates a commit object and returns its hash.

(details *CommitDetails)

Source from the content-addressed store, hash-verified

628
629// CreateCommit creates a commit object and returns its hash.
630func (repo *GitRepo) CreateCommit(details *CommitDetails) (string, error) {
631 args := []string{"commit-tree", details.Tree, "-m", details.Summary}
632 for _, parent := range details.Parents {
633 args = append(args, "-p", parent)
634 }
635 var env []string
636 if details.Author != "" {
637 env = append(env, fmt.Sprintf("GIT_AUTHOR_NAME=%s", details.Author))
638 }
639 if details.AuthorEmail != "" {
640 env = append(env, fmt.Sprintf("GIT_AUTHOR_EMAIL=%s", details.AuthorEmail))
641 }
642 if details.AuthorTime != "" {
643 env = append(env, fmt.Sprintf("GIT_AUTHOR_DATE=%s", details.AuthorTime))
644 }
645 if details.Committer != "" {
646 env = append(env, fmt.Sprintf("GIT_COMMITTER_NAME=%s", details.Committer))
647 }
648 if details.CommitterEmail != "" {
649 env = append(env, fmt.Sprintf("GIT_COMMITTER_EMAIL=%s", details.CommitterEmail))
650 }
651 if details.Time != "" {
652 env = append(env, fmt.Sprintf("GIT_COMMITTER_DATE=%s", details.Time))
653 }
654 return repo.runGitCommandWithEnv(env, args...)
655}
656
657// CreateCommitWithTree creates a commit object with the given tree and returns its hash.
658func (repo *GitRepo) CreateCommitWithTree(details *CommitDetails, t *Tree) (string, error) {

Callers 1

CreateCommitWithTreeMethod · 0.95

Calls 1

runGitCommandWithEnvMethod · 0.95

Tested by

no test coverage detected