Skip to content

Commit c2de63f

Browse files
committed
GPG signed commit handling
1 parent a4c37cd commit c2de63f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

git_wapper.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ func commit(msg commitMsg) error {
3939
return err
4040
}
4141

42-
_, err = git("commit", "-F", f.Name())
42+
gpgSignedCommit := ""
43+
if hasGPGSignedCommit() {
44+
gpgSignedCommit = "-S"
45+
}
46+
_, err = git("commit", gpgSignedCommit, "-F", f.Name())
4347
if err != nil {
4448
return err
4549
}
@@ -65,6 +69,15 @@ func push() (string, error) {
6569
return msg, err
6670
}
6771

72+
func hasGPGSignedCommit() bool {
73+
msg, err := git("config", "--get", "commit.gpgsign")
74+
if err != nil {
75+
fmt.Println("Cannot verify if GPG sign commit because", err)
76+
return false
77+
}
78+
return msg == "true"
79+
}
80+
6881
func hasStagedFiles() error {
6982
msg, err := git("diff", "--cached", "--name-only")
7083
if err != nil {

0 commit comments

Comments
 (0)