diff options
| author | Jann Fischer <jann@mistrust.net> | 2024-07-05 09:26:01 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-05 09:26:01 -0400 |
| commit | 7f93ac538917325afd05e5ca6a18f423fa503195 (patch) | |
| tree | 73ba5033358b865093732c4ccd77fa6529217685 | |
| parent | ae3eec3ff69487d13da770abd9167c61ac957931 (diff) | |
fix: Fix write-back commits (#767)
Signed-off-by: jannfis <jann@mistrust.net>
| -rw-r--r-- | Dockerfile | 2 | ||||
| -rw-r--r-- | ext/git/writer.go | 12 |
2 files changed, 11 insertions, 3 deletions
@@ -14,7 +14,7 @@ FROM alpine:3.19 RUN apk update && \ apk upgrade && \ - apk add ca-certificates git openssh-client aws-cli tini && \ + apk add ca-certificates git openssh-client aws-cli tini gpg && \ rm -rf /var/cache/apk/* RUN mkdir -p /usr/local/bin diff --git a/ext/git/writer.go b/ext/git/writer.go index 94535ae..9178865 100644 --- a/ext/git/writer.go +++ b/ext/git/writer.go @@ -32,13 +32,21 @@ func (m *nativeGitClient) Commit(pathSpec string, opts *CommitOptions) error { defaultCommitMsg := "Update parameters" // Git configuration config := "gpg.format=" + opts.SigningMethod - args := []string{"-c", config, "commit"} + args := []string{} + // -c is a global option and needs to be passed before the actual git sub + // command (commit). + if opts.SigningMethod != "" { + args = append(args, "-c", config) + } + args = append(args, "commit") if pathSpec == "" || pathSpec == "*" { args = append(args, "-a") } // Commit fails with a space between -S flag and path to SSH key // -S/user/test/.ssh/signingKey or -SAAAAAAAA... - args = append(args, fmt.Sprintf("-S%s", opts.SigningKey)) + if opts.SigningKey != "" { + args = append(args, fmt.Sprintf("-S%s", opts.SigningKey)) + } if opts.SignOff { args = append(args, "-s") } |
