Core-workflow: bot to automatically close PRs that merge maintenance branch into master

Created on 26 Jul 2017  路  15Comments  路  Source: python/core-workflow

I've closed a number of PRs where contributor tries to merge one of the maintenance branches into master:
(e.g. 3.6 into master or 3.5 into master)

https://github.com/python/cpython/pull/2901
https://github.com/python/cpython/pull/2784
https://github.com/python/cpython/pull/2678
https://github.com/python/cpython/pull/2427
https://github.com/python/cpython/pull/1968

Would be great if somehow we can disallow this type of PR, or automatically close the PR once created.

From GitHub Web UI, each of these PRs are showing maybe hundreds of commits.
It's inconvenient to scroll all the way to the bottom to find the Close button 馃槥

bot

Most helpful comment

So ^python:(master|\d+\.\d+)$? I guess it's easier to just not worry about alphas and such and assume people won't slip up like they have with the mainline branches.

All 15 comments

Looking at https://api.github.com/repos/python/cpython/pulls/2901 maybe if we checked head/ref and base/ref to make sure they both aren't master or \d+.\d+? Something I'm not sure about, though, is what if someone forks and simply commits into their e.g. master branch and creates a PR from that?

I think the main issue here is a GitHub bug; it should not be possible for a non-team member to click the "New pull request" button on the branches page. As a defense against that, we could check that head.label and base.label don't both match python:(master|\d+.\d+).

@zware just for my own edification, what exactly does *.label represent and why does having the python bit guarantee it's only those branches off of the cpython repo and not someone who just edited master on their personal fork?

@brettcannon *.label is just something I picked out from the api.github.com link for 2901 that you included above; it seems to be basically f'{head.repo.owner.login}:{ref}'. So in 2901, head.label was python:3.6 and base.label is python:master, while in 18 (a legitimate PR) head.label was rogersachan:master with base.label python:master. You could also directly check whether head.repo.owner.login is python and reject the PR if head.ref matches ^(master|\d+.\d+)$ since we don't do merges between branches anymore.

(Sorry for the delay in answer, I'm still in the midst of moving house.)

@zware thanks for the info!

And no need to apologize! This is not exactly holding anything up and real life always takes precedence over volunteer life. Hope the move is going smoothly!

So it would seem if a PR has a head.label matching python:(master|\d+\.\d+((a|b|rc)\d+)?) that's good enough and has simpler logic than having to check both login and ref. Does that sound reasonable?

I'm not sure about the ((a|b|rc)\d+)? part; we may want some release manager input on that (do release managers create branches in the main repo during the release process that then get merged?). We should probably also explicitly match beginning and end of string, so that we don't reject something like ilikepython:3.6-backport-of-some-issue.

Otherwise, sounds good to me :)

So ^python:(master|\d+\.\d+)$? I guess it's easier to just not worry about alphas and such and assume people won't slip up like they have with the mainline branches.

Happened twice yesterday:
https://github.com/python/cpython/pull/3455
https://github.com/python/cpython/pull/3449
We have codeowners now, I'm guessing many people are getting spammed unnecessarily with this type of PRs 馃槥

Both of those PRs are from people who have not even forked cpython. I think that they should be reported to github support (button on their profile pages) as we may not be the only target of such abuse. Let GH support investigate their history and decide on appropriate action.

I've just sent a message to GH support about it.

Thanks @terryjreedy @zware

I've had a response from GH support; they're investigating those two particular users and have relayed my feedback on removing the 'new pull request' button for those with no write access.

I've also mentioned python/cpython#3621 to GH support, and asked for an update on removing the button.

Just reported python/cpython#3689 as well. No news on a fix, but my "feedback is being discussed internally".

Was this page helpful?
0 / 5 - 0 ratings