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
Conversation
fdfb80b
to
e15bcd2
Compare
| 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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
e15bcd2
to
35b809f
Compare
There was a problem hiding this 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"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
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. |
Most of what you see in the diff is just moving around code. The only new code is in the
merge_prfunction.