Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fastforward git user configuration #2503

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}