Skip to content

Commit ed28fed

Browse files
committed
tide: fallback to individual PR merge in batch failures
1 parent 8026e80 commit ed28fed

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

pkg/tide/tide.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,15 @@ func (c *syncController) takeAction(sp subpool, batchPending, successes, pending
14391439
// Merge the batch!
14401440
if len(batchMerges) > 0 {
14411441
merged, err = c.provider.mergePRs(sp, batchMerges, c.statusUpdate.dontUpdateStatus)
1442-
return MergeBatch, batchMerges, err
1442+
// If the entire batch failed to merge (e.g., due to conflicts), fall through
1443+
// to attempt merging individual PRs to break the tie.
1444+
if len(merged) > 0 {
1445+
return MergeBatch, batchMerges, err
1446+
}
1447+
if ok, pr := pickHighestPriorityPR(sp.log, batchMerges, sp.cc, c.isPassingTests, c.config().Tide.Priority); ok {
1448+
merged, err = c.provider.mergePRs(sp, []CodeReviewCommon{pr}, c.statusUpdate.dontUpdateStatus)
1449+
return Merge, []CodeReviewCommon{pr}, err
1450+
}
14431451
}
14441452
// Do not merge PRs while waiting for a batch to complete. We don't want to
14451453
// invalidate the old batch result.

pkg/tide/tide_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,17 @@ func testTakeAction(clients localgit.Clients, t *testing.T) {
19591959
action: Trigger,
19601960
enableScheduling: true,
19611961
},
1962+
{
1963+
name: "batch merge fails, falls back to individual PR merge (issue #474)",
1964+
batchMerges: []int{0, 1},
1965+
mergeErrs: map[int]error{
1966+
0: github.UnmergablePRError("merge conflict"),
1967+
1: github.UnmergablePRError("merge conflict"),
1968+
},
1969+
merged: 0,
1970+
triggered: 0,
1971+
action: Merge,
1972+
},
19621973
}
19631974

19641975
for _, tc := range testcases {

0 commit comments

Comments
 (0)