You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bot to automatically close PRs that merge maintenance branch into master #168
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 😞
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.labelpython: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.)
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.
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: python/cpython#3455 python/cpython#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 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.
Activity
brettcannon commentedon Jul 27, 2017
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
masteror\d+.\d+? Something I'm not sure about, though, is what if someone forks and simply commits into their e.g.masterbranch and creates a PR from that?zware commentedon Jul 27, 2017
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.labelandbase.labeldon't both matchpython:(master|\d+.\d+).brettcannon commentedon Jul 28, 2017
@zware just for my own edification, what exactly does
*.labelrepresent and why does having thepythonbit guarantee it's only those branches off of the cpython repo and not someone who just editedmasteron their personal fork?zware commentedon Aug 1, 2017
@brettcannon
*.labelis just something I picked out from the api.github.com link for 2901 that you included above; it seems to be basicallyf'{head.repo.owner.login}:{ref}'. So in 2901,head.labelwaspython:3.6andbase.labelispython:master, while in 18 (a legitimate PR)head.labelwasrogersachan:masterwithbase.labelpython:master. You could also directly check whetherhead.repo.owner.loginispythonand reject the PR ifhead.refmatches^(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.)
brettcannon commentedon Aug 3, 2017
@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!
brettcannon commentedon Aug 3, 2017
So it would seem if a PR has a
head.labelmatchingpython:(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?zware commentedon Aug 3, 2017
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 likeilikepython:3.6-backport-of-some-issue.Otherwise, sounds good to me :)
brettcannon commentedon Aug 3, 2017
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.Mariatta commentedon Sep 8, 2017
Happened twice yesterday:
python/cpython#3455
python/cpython#3449
We have codeowners now, I'm guessing many people are getting spammed unnecessarily with this type of PRs 😞
terryjreedy commentedon Sep 8, 2017
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.
zware commentedon Sep 8, 2017
I've just sent a message to GH support about it.
Mariatta commentedon Sep 8, 2017
Thanks @terryjreedy @zware
zware commentedon Sep 8, 2017
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.
zware commentedon Sep 18, 2017
I've also mentioned python/cpython#3621 to GH support, and asked for an update on removing the button.
Close PR that tries to merge maintenance branch into master
zware commentedon Sep 21, 2017
Just reported python/cpython#3689 as well. No news on a fix, but my "feedback is being discussed internally".