Skip to content

Commit

Permalink
Fix fastforward git user configuration
Browse files Browse the repository at this point in the history
The recent git auto fast forward jobs fails because of the misconfigured
git user:

https://storage.googleapis.com/kubernetes-jenkins/logs/ci-fast-forward/1516649755411746816/build-log.txt

```
Step #3: level=info msg="Merging main branch changes into release branch"
Step #3: level=fatal msg="merge main ref: run git merge: command /usr/bin/git merge -X ours origin/master did not succeed: Committer identity unknown\n\n*** Please tell me who you are.\n\nRun\n\n  git config --global user.email \"you@example.com\"\n  git config --global user.name \"Your Name\"\n\nto set your account's default identity.\nOmit --global to set the identity only in this repository.\n\nfatal: unable to auto-detect email address (got 'root@c96ac26cb82d.(none)')\n"
Finished Step #3
ERROR
```

We now fix this by doing the same configuration like we do in krel
stage and release.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
  • Loading branch information
saschagrunert committed Apr 20, 2022
1 parent 0a3425c commit 814e655
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/fastforward/fastforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ func (f *FastForward) Run() (err error) {
}
logrus.Infof("Latest release branch revision is %s", releaseRev)

logrus.Info("Configuring git user and email")
if err := f.ConfigureGlobalDefaultUserAndEmail(); err != nil {
return errors.Wrap(err, "configure git user and email")
}

logrus.Info("Merging main branch changes into release branch")
if err := f.RepoMerge(repo, f.options.MainRef); err != nil {
return errors.Wrap(err, "merge main ref")
Expand Down
11 changes: 11 additions & 0 deletions pkg/fastforward/fastforward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ func TestRun(t *testing.T) {
require.NotNil(t, err)
},
},
{ // failure on ConfigureGlobalDefaultUserAndEmail
prepare: func(mock *fastforwardfakes.FakeImpl) *Options {
mock.IsReleaseBranchReturns(true)
mock.RepoHasRemoteBranchReturns(true, nil)
mock.ConfigureGlobalDefaultUserAndEmailReturns(errTest)
return &Options{Branch: branch}
},
assert: func(err error) {
require.NotNil(t, err)
},
},
{ // failure on RepoMergeBase
prepare: func(mock *fastforwardfakes.FakeImpl) *Options {
mock.IsReleaseBranchReturns(true)
Expand Down
65 changes: 65 additions & 0 deletions pkg/fastforward/fastforwardfakes/fake_impl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/fastforward/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type impl interface {
RemoveAll(string) error
MkdirTemp(string, string) (string, error)
Exists(string) bool
ConfigureGlobalDefaultUserAndEmail() error
}

func (*defaultImpl) CloneOrOpenDefaultGitHubRepoSSH(repo string) (*git.Repo, error) {
Expand Down Expand Up @@ -158,3 +159,7 @@ func (*defaultImpl) MkdirTemp(dir, pattern string) (string, error) {
func (*defaultImpl) Exists(path string) bool {
return util.Exists(path)
}

func (*defaultImpl) ConfigureGlobalDefaultUserAndEmail() error {
return git.ConfigureGlobalDefaultUserAndEmail()
}

0 comments on commit 814e655

Please sign in to comment.