Skip to content

Commit 97252a7

Browse files
authored
Retry commit if signing fails (#277)
This commit modifies the clone commit code to retry with the pure go commit implementation if signing fails. It will only do so if 1) UseGit was not specified and 2) Signing was not specified. Signed-off-by: Adolfo Garcia Veytia (puerco) <[email protected]>
1 parent 77fc6e7 commit 97252a7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/repo/clone.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"log"
1111
"os"
1212
"os/exec"
13+
"strings"
1314

1415
billy "github.com/go-git/go-billy/v6"
1516
git "github.com/go-git/go-git/v6"
@@ -159,7 +160,14 @@ func (c *Clone) Commit(opts *options.CommitOptions) error {
159160
usegit = *opts.UseGit
160161
}
161162
if usegit {
162-
return c.gitCliCommit(opts)
163+
if err := c.gitCliCommit(opts); err != nil {
164+
// If signing is not defined and the commit failed
165+
// signing, try again with the pure go signature.
166+
if opts.Sign == nil && opts.UseGit == nil && strings.Contains(err.Error(), "gpg failed") {
167+
return c.puregoCommit(opts)
168+
}
169+
return err
170+
}
163171
}
164172
return c.puregoCommit(opts)
165173
}

0 commit comments

Comments
 (0)