Skip to content
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
3 changes: 2 additions & 1 deletion scripts/ci/pr_review_merge_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ def compare_behind_by(pr: dict[str, Any]) -> int:

def branch_outdated_by_base(pr: dict[str, Any], merge_state: str) -> int:
"""Return known count of base commits missing from the PR head."""
if merge_state == "BEHIND":
compare_status = (pr.get("compareStatus") or "").lower()
if merge_state == "BEHIND" or compare_status == "behind":
return max(1, compare_behind_by(pr))
return compare_behind_by(pr)

Expand Down
21 changes: 21 additions & 0 deletions tests/test_pr_review_merge_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,27 @@ def test_inspect_pr_blocks_and_waits_for_policy_states(monkeypatch):
assert "existing auto-merge request remains queued" in blocked_without_opencode_decision.reason
assert called == [("owner/repo", 1, True)]
called.clear()
blocked_compare_behind_auto = make_pr(
mergeStateStatus="BLOCKED",
restMergeableState="BLOCKED",
compareStatus="behind",
autoMergeRequest={"enabledAt": "now"},
statusCheckRollup={
"contexts": {
"nodes": [
{"__typename": "CheckRun", "name": "strix", "conclusion": "FAILURE"},
{"__typename": "CheckRun", "name": "coverage-evidence", "conclusion": "FAILURE"},
],
}
},
)
blocked_compare_behind_decision = inspect(blocked_compare_behind_auto)
assert blocked_compare_behind_decision.action == "update_branch"
assert "auto-merge already enabled" in blocked_compare_behind_decision.reason
assert "base branch is 1 commit(s) ahead" in blocked_compare_behind_decision.reason
assert "existing auto-merge request remains queued" in blocked_compare_behind_decision.reason
assert called == [("owner/repo", 1, True)]
called.clear()
disabled.clear()
assert (
inspect(blocked_failed_behind_auto_without_opencode_approval, update_branches=False).reason
Expand Down
Loading