From 1c6edd8ef6546ee1cbfd07968dedde22d570ffff Mon Sep 17 00:00:00 2001 From: Steve Cosenza Date: Wed, 22 Nov 2023 09:26:20 -0800 Subject: [PATCH] Add BranchPushIndividually repo config Instead of always pushing branches atomically (which can result in timeouts in larger and slower monorepos), add a BranchPushIndividually repo config setting which enables pushing each branch one at a time. --- config/config.go | 3 ++- readme.md | 1 + spr/spr.go | 14 +++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index dbb9799..1e40f92 100644 --- a/config/config.go +++ b/config/config.go @@ -37,7 +37,8 @@ type RepoConfig struct { ForceFetchTags bool `default:"false" yaml:"forceFetchTags"` - ShowPrTitlesInStack bool `default:"false" yaml:"showPrTitlesInStack"` + ShowPrTitlesInStack bool `default:"false" yaml:"showPrTitlesInStack"` + BranchPushIndividually bool `default:"false" yaml:"branchPushIndividually"` } type UserConfig struct { diff --git a/readme.md b/readme.md index 316bd49..df067a2 100644 --- a/readme.md +++ b/readme.md @@ -167,6 +167,7 @@ User specific configuration is saved to .spr.yml in the user home directory. | forceFetchTags | bool | false | also fetch tags when running 'git spr update' | | branchNameIncludeTarget | bool | false | include target branch name in pull request branch name | | showPrTitlesInStack | bool | false | show PR titles in stack description within pull request body | +| branchPushIndividually | bool | false | push branches individually instead of atomically (only enable to avoid timeouts) | | User Config | Type | Default | Description | diff --git a/spr/spr.go b/spr/spr.go index b43c8f6..7058eeb 100644 --- a/spr/spr.go +++ b/spr/spr.go @@ -543,10 +543,18 @@ func (sd *stackediff) syncCommitStackToGitHub(ctx context.Context, refNames = append(refNames, commit.CommitHash+":refs/heads/"+branchName) } + if len(updatedCommits) > 0 { - pushCommand := fmt.Sprintf("push --force --atomic %s ", sd.config.Repo.GitHubRemote) - pushCommand += strings.Join(refNames, " ") - sd.gitcmd.MustGit(pushCommand, nil) + if sd.config.Repo.BranchPushIndividually { + for _, refName := range refNames { + pushCommand := fmt.Sprintf("push --force %s %s", sd.config.Repo.GitHubRemote, refName) + sd.gitcmd.MustGit(pushCommand, nil) + } + } else { + pushCommand := fmt.Sprintf("push --force --atomic %s ", sd.config.Repo.GitHubRemote) + pushCommand += strings.Join(refNames, " ") + sd.gitcmd.MustGit(pushCommand, nil) + } } sd.profiletimer.Step("SyncCommitStack::PushBranches") return true