Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bot): don't attempt merge on changes requested #765

Merged
merged 2 commits into from
Nov 25, 2021
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
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