From 7f93ac538917325afd05e5ca6a18f423fa503195 Mon Sep 17 00:00:00 2001 From: Jann Fischer Date: Fri, 5 Jul 2024 09:26:01 -0400 Subject: fix: Fix write-back commits (#767) Signed-off-by: jannfis --- Dockerfile | 2 +- ext/git/writer.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e294a17..fa0d501 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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") } -- cgit v1.2.3