diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-08-05 10:30:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-05 10:30:24 +0100 |
commit | cd6170c6f808453f58dcfd15c6c59345e3df402b (patch) | |
tree | 15c5e333b93641f9eadcb4bf4b34c338135f7a23 /options.go | |
parent | 4ec6b3f4fa9cdfe8f10d0953ac7d398d01a90f17 (diff) | |
parent | e6f68d2e4cd1bc4447126816c7c27e1fc2098e30 (diff) | |
download | go-git-cd6170c6f808453f58dcfd15c6c59345e3df402b.tar.gz |
Merge pull request #438 from john-cai/jc/commit-ammend
Add Amend option to CommitOptions
Diffstat (limited to 'options.go')
-rw-r--r-- | options.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -498,10 +498,21 @@ type CommitOptions struct { // commit will not be signed. The private key must be present and already // decrypted. SignKey *openpgp.Entity + // Amend will create a new commit object and replace the commit that HEAD currently + // points to. Cannot be used with All nor Parents. + Amend bool } // Validate validates the fields and sets the default values. func (o *CommitOptions) Validate(r *Repository) error { + if o.All && o.Amend { + return errors.New("all and amend cannot be used together") + } + + if o.Amend && len(o.Parents) > 0 { + return errors.New("parents cannot be used with amend") + } + if o.Author == nil { if err := o.loadConfigAuthorAndCommitter(r); err != nil { return err |