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

Have PR processor automatically merge PRs #737

Closed
wants to merge 1 commit into from

Conversation

daviddavis
Copy link
Contributor

@daviddavis daviddavis commented Sep 28, 2020

Most of what you see in the diff is just moving around code. The only new code is in the merge_pr function.

Comment on lines +116 to +144
def merge_pr(pr):
"""Check if a PR is ready for merge and if so, attempt to merge it."""
print(f"Checking PR {pr.number} to see if it's mergeable.")

if pr.draft:
print(f"PR {pr.number} is a draft, skipping merge.")
return

if pr.get_reviews().totalCount < 1:
# technically not required if branch protection is set up properly since
# mergeable_state will say "blocking" if there aren't enough reviews
print(f"PR {pr.number} has not been reviewed, skipping merge.")
return

if pr.mergeable_state != "clean":
print(f"PR {pr.number} has state {pr.mergeable_state}, skipping merge.")
return

if any(commit for commit in pr.get_commits() if
commit.raw_data["commit"]["verification"]["verified"]):
merge_method = "merge"
else:
merge_method = "rebase"

pr.merge(merge_method=merge_method)
print(f"Merged PR {pr.number} by {merge_method} method.\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@daviddavis daviddavis marked this pull request as draft September 28, 2020 15:29
@fao89 fao89 requested review from fao89 and removed request for fao89 September 29, 2020 14:42
@daviddavis daviddavis marked this pull request as ready for review October 13, 2020 14:56
Copy link
Member

@bmbouter bmbouter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm excited for this! The code looks good.

return

if any(commit for commit in pr.get_commits() if
commit.raw_data["commit"]["verification"]["verified"]):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@ipanova ipanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@daviddavis
Copy link
Contributor Author

Closing out due to inactivity. It seems like there are now github actions that can auto-merge as well if we want to do that.

@daviddavis daviddavis closed this Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants