diff --git a/pkg/argocd/git.go b/pkg/argocd/git.go index 7d30cec3..71422c2e 100644 --- a/pkg/argocd/git.go +++ b/pkg/argocd/git.go @@ -158,14 +158,6 @@ func commitChangesGit(app *v1alpha1.Application, wbc *WriteBackConfig, changeLis return err } - // Set username and e-mail address used to identify the commiter - if wbc.GitCommitUser != "" && wbc.GitCommitEmail != "" { - err = gitC.Config(wbc.GitCommitUser, wbc.GitCommitEmail) - if err != nil { - return err - } - } - // The branch to checkout is either a configured branch in the write-back // config, or taken from the application spec's targetRevision. If the // target revision is set to the special value HEAD, or is the empty @@ -247,6 +239,14 @@ func commitChangesGit(app *v1alpha1.Application, wbc *WriteBackConfig, changeLis defer os.Remove(cm.Name()) } + // Set username and e-mail address used to identify the commiter + if wbc.GitCommitUser != "" && wbc.GitCommitEmail != "" { + err = gitC.Config(wbc.GitCommitUser, wbc.GitCommitEmail) + if err != nil { + return err + } + } + if wbc.GitCommitSigningKey != "" { commitOpts.SigningKey = wbc.GitCommitSigningKey } diff --git a/pkg/argocd/update_test.go b/pkg/argocd/update_test.go index 416de5d3..1bd1d3e2 100644 --- a/pkg/argocd/update_test.go +++ b/pkg/argocd/update_test.go @@ -3363,6 +3363,7 @@ replacements: [] app := app.DeepCopy() gitMock := &gitmock.Client{} gitMock.On("Init").Return(nil) + gitMock.On("Root").Return(t.TempDir()) gitMock.On("ShallowFetch", mock.Anything, mock.Anything).Return(nil) gitMock.On("Checkout", mock.Anything, mock.Anything).Run(func(args mock.Arguments) { args.Assert(t, "mydefaultbranch", false)