Skip to content

Commit

Permalink
Add BranchPushIndividually repo config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Steve Cosenza authored and ejoffe committed Dec 18, 2023
1 parent 66dd2f0 commit 1c6edd8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
14 changes: 11 additions & 3 deletions spr/spr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c6edd8

Please sign in to comment.