Skip to content

Commit

Permalink
After merge cleanup branch error suppresion
Browse files Browse the repository at this point in the history
GitHub might also delete the branch, causing an error when trying
to delete a branch that's gone.
After merge make the branch cleanup command be best effort, with no error.

Fixes:#53

commit-id:751827cf
  • Loading branch information
ejoffe committed Jun 22, 2021
1 parent 6926edd commit edf19ff
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions spr/spr.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,7 @@ func (sd *stackediff) MergePullRequests(ctx context.Context) {
sd.profiletimer.Step("MergePullRequests::merge pr")

if sd.config.CleanupRemoteBranch {
err := sd.gitcmd.Git(fmt.Sprintf("push -d origin %s", prToMerge.FromBranch), nil)
if err != nil {
fmt.Fprintf(sd.writer, "error deleting branch: %v\n", err)
}
sd.gitcmd.Git(fmt.Sprintf("push -d origin %s", prToMerge.FromBranch), nil)
}

// Close all the pull requests in the stack below the merged pr
Expand All @@ -211,10 +208,7 @@ func (sd *stackediff) MergePullRequests(ctx context.Context) {
sd.github.ClosePullRequest(ctx, pr)

if sd.config.CleanupRemoteBranch {
err := sd.gitcmd.Git(fmt.Sprintf("push -d origin %s", pr.FromBranch), nil)
if err != nil {
fmt.Fprintf(sd.writer, "error deleting branch: %v\n", err)
}
sd.gitcmd.Git(fmt.Sprintf("push -d origin %s", pr.FromBranch), nil)
}
}
sd.profiletimer.Step("MergePullRequests::close prs")
Expand Down

0 comments on commit edf19ff

Please sign in to comment.