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

ref(notifications): improve github check messages for PR status #72

Merged
merged 6 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 9 additions & 0 deletions kodiak/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,23 @@ class MissingAppID(BaseException):
another instance of kodiak.
"""

def __str__(self) -> str:
return "missing Github app id"


class BranchMerged(BaseException):
"""branch has already been merged"""

def __str__(self) -> str:
return str(self.__doc__)


class MergeConflict(BaseException):
"""Merge conflict in the PR."""

def __str__(self) -> str:
return "merge conflict"


def review_status(reviews: typing.List[PRReview]) -> PRReviewState:
"""
Expand Down
33 changes: 16 additions & 17 deletions kodiak/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,24 @@ async def mergeability(
valid_merge_methods=self.event.valid_merge_methods,
)
self.log.info("okay")
await self.set_status(summary="⛴ ready to merge")
return MergeabilityResponse.OK, self.event
except MissingAppID:
return MergeabilityResponse.NOT_MERGEABLE, self.event
except NotQueueable as e:
await self.set_status(summary="🛑 cannot merge", detail=str(e))
return MergeabilityResponse.NOT_MERGEABLE, self.event
except MergeConflict:
await self.set_status(summary="🛑 cannot merge", detail="merge conflict")
if self.event.config.merge.notify_on_conflict:
except (NotQueueable, MissingAppID, MergeConflict, BranchMerged) as e:
if (
isinstance(e, MergeConflict)
and self.event.config.merge.notify_on_conflict
):
await self.notify_pr_creator()

if (
isinstance(e, BranchMerged)
and self.event.config.merge.delete_branch_on_merge
):
await self.client.delete_branch(
branch=self.event.pull_request.headRefName
)

await self.set_status(summary="🛑 cannot merge", detail=str(e))
return MergeabilityResponse.NOT_MERGEABLE, self.event
except MissingGithubMergeabilityState:
self.log.info("missing mergeability state, need refresh")
Expand All @@ -170,15 +178,6 @@ async def mergeability(
except NeedsBranchUpdate:
await self.set_status(summary="⏭ need update")
return MergeabilityResponse.NEEDS_UPDATE, self.event
except BranchMerged:
await self.set_status(
summary="🛑 cannot merge", detail="branch merged already"
)
if self.event.config.merge.delete_branch_on_merge:
await self.client.delete_branch(
branch=self.event.pull_request.headRefName
)
return MergeabilityResponse.NOT_MERGEABLE, self.event

async def update(self) -> None:
self.log.info("update")
Expand Down