@@ -107,14 +107,30 @@ func AddChanges(repoPath string, all bool, files ...string) error {
107107 return err
108108}
109109
110- // CommitChanges commits local changes with given message and author.
111- func CommitChanges (repoPath , message string , author * Signature ) error {
112- cmd := NewCommand ("commit" , "-m" , message )
113- if author != nil {
114- cmd .AddArguments (fmt .Sprintf ("--author='%s <%s>'" , author .Name , author .Email ))
110+ type CommitChangesOptions struct {
111+ Committer * Signature
112+ Author * Signature
113+ Message string
114+ }
115+
116+ // CommitChanges commits local changes with given committer, author and message.
117+ // If author is nil, it will be the same as committer.
118+ func CommitChanges (repoPath string , opts CommitChangesOptions ) error {
119+ cmd := NewCommand ()
120+ if opts .Committer != nil {
121+ cmd .AddArguments ("-c" , "user.name=" + opts .Committer .Name , "-c" , "user.email=" + opts .Committer .Email )
115122 }
116- _ , err := cmd .RunInDir ( repoPath )
123+ cmd .AddArguments ( "commit" )
117124
125+ if opts .Author == nil {
126+ opts .Author = opts .Committer
127+ }
128+ if opts .Author != nil {
129+ cmd .AddArguments (fmt .Sprintf ("--author='%s <%s>'" , opts .Author .Name , opts .Author .Email ))
130+ }
131+ cmd .AddArguments ("-m" , opts .Message )
132+
133+ _ , err := cmd .RunInDir (repoPath )
118134 // No stderr but exit status 1 means nothing to commit.
119135 if err != nil && err .Error () == "exit status 1" {
120136 return nil
0 commit comments