Skip to content

Commit

Permalink
fix(bot): don't attempt merge on changes requested (#765)
Browse files Browse the repository at this point in the history
A regression was introduced with #762 that caused the bot to attempt to update pull requests when changes were requested. This change fixes that issue.

related #761
  • Loading branch information
chdsbd authored Nov 25, 2021
1 parent 444145f commit f54f9cc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bot/kodiak/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,10 @@ async def set_status(msg: str, markdown_content: Optional[str] = None) -> None:
await block_merge(api, pull_request, "missing required reviews")
return

if pull_request.reviewDecision == PullRequestReviewDecision.CHANGES_REQUESTED:
await block_merge(api, pull_request, "changes requested")
return

if (
branch_protection.requiresConversationResolution
and pull_request.reviewThreads.nodes is not None
Expand Down
26 changes: 26 additions & 0 deletions bot/kodiak/tests/evaluation/test_branch_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,32 @@ async def test_mergeable_missing_required_review() -> None:
assert api.queue_for_merge.called is False


@pytest.mark.asyncio
async def test_mergeable_missing_changes_requested() -> None:
"""
Don't merge when a changes requested.
"""
api = create_api()
mergeable = create_mergeable()
pull_request = create_pull_request()

pull_request.mergeStateStatus = MergeStateStatus.BEHIND
pull_request.reviewDecision = PullRequestReviewDecision.CHANGES_REQUESTED

await mergeable(
api=api,
pull_request=pull_request,
)
assert api.set_status.call_count == 1
assert api.dequeue.call_count == 1
assert "changes requested" in api.set_status.calls[0]["msg"]

# verify we haven't tried to update/merge the PR
assert api.update_branch.called is False
assert api.merge.called is False
assert api.queue_for_merge.called is False


@pytest.mark.asyncio
async def test_mergeable_update_branch_immediately() -> None:
"""
Expand Down

0 comments on commit f54f9cc

Please sign in to comment.