Skip to content

Commit

Permalink
Account for the renaming of the 'master' branch to 'main'
Browse files Browse the repository at this point in the history
Closes: python#337
  • Loading branch information
pablogsal committed May 3, 2021
1 parent d302d1f commit c895997
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bedevere/backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def validate_maintenance_branch_pr(event, gh, *args, **kwargs):
pull_request = event.data["pull_request"]
base_branch = pull_request["base"]["ref"]

if base_branch == "master":
if base_branch == "main":
return

title = util.normalize_title(pull_request["title"],
Expand Down
12 changes: 6 additions & 6 deletions bedevere/close_pr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Automatically close PR that tries to merge maintenance branch into master."""
"""Automatically close PR that tries to merge maintenance branch into main."""
import re

import gidgethub.routing
Expand All @@ -8,7 +8,7 @@

INVALID_PR_COMMENT = """\
PRs attempting to merge a maintenance branch into the \
master branch are deemed to be spam and automatically closed. \
main branch are deemed to be spam and automatically closed. \
If you were attempting to report a bug, please go to bugs.python.org; \
see devguide.python.org for further instruction as needed."""

Expand All @@ -21,14 +21,14 @@ async def close_invalid_pr(event, gh, *args, **kwargs):
"""Close the invalid PR, add 'invalid' label, and post a message.
PR is considered invalid if:
* base_label is 'python:master'
* base_label is 'python:main'
* head_label is '<username>:<maint_branch>'
"""
head_label = event.data["pull_request"]["head"]["label"]
base_label = event.data["pull_request"]["base"]["label"]

if PYTHON_MAINT_BRANCH_RE.match(head_label) and \
base_label == "python:master":
base_label == "python:main":
data = {'state': 'closed'}
await gh.patch(event.data["pull_request"]["url"], data=data)
await gh.post(
Expand All @@ -46,14 +46,14 @@ async def dismiss_invalid_pr_review_request(event, gh, *args, **kwargs):
"""Dismiss review request from the invalid PR.
PR is considered invalid if:
* base_label is 'python:master'
* base_label is 'python:main'
* head_label is '<username>:<maint_branch>'
"""
head_label = event.data["pull_request"]["head"]["label"]
base_label = event.data["pull_request"]["base"]["label"]

if PYTHON_MAINT_BRANCH_RE.match(head_label) and \
base_label == "python:master":
base_label == "python:main":
data = {"reviewers": [reviewer["login"] for reviewer in event.data["pull_request"]["requested_reviewers"]],
"team_reviewers": [team["name"] for team in event.data["pull_request"]["requested_teams"]]
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ async def test_not_valid_maintenance_branch_pr_title(action):


@pytest.mark.parametrize('action', ['opened', 'reopened', 'edited', 'synchronize'])
async def test_maintenance_branch_pr_status_not_posted_on_master(action):
async def test_maintenance_branch_pr_status_not_posted_on_main(action):
title = 'Fix some typo'
data = {
'action': action,
Expand All @@ -339,7 +339,7 @@ async def test_maintenance_branch_pr_status_not_posted_on_master(action):
'body': '',
'issue_url': 'https://api.github.com/issue/2248',
'base': {
'ref': 'master',
'ref': 'main',
},
'statuses_url': 'https://api.github.com/repos/python/cpython/statuses/somehash',
},
Expand Down
14 changes: 7 additions & 7 deletions tests/test_close_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def test_close_invalid_pr_on_open():
"label": "python:3.6"
},
"base": {
"label": "python:master"
"label": "python:main"
}
},
}
Expand Down Expand Up @@ -80,7 +80,7 @@ async def test_close_invalid_pr_on_synchronize():
"label": "python:3.6"
},
"base": {
"label": "python:master"
"label": "python:main"
}
},
}
Expand Down Expand Up @@ -115,7 +115,7 @@ async def test_valid_pr_not_closed():
"label": "someuser:bpo-3.6"
},
"base": {
"label": "python:master"
"label": "python:main"
}
},
}
Expand Down Expand Up @@ -144,7 +144,7 @@ async def test_close_invalid_pr_on_open_not_python_as_head():
"label": "username123:3.6"
},
"base": {
"label": "python:master"
"label": "python:main"
}
},
}
Expand Down Expand Up @@ -173,7 +173,7 @@ async def test_pr_with_head_branch_containing_all_digits_not_closed():
"label": "someuser:12345"
},
"base": {
"label": "python:master"
"label": "python:main"
}
},
}
Expand Down Expand Up @@ -203,7 +203,7 @@ async def test_dismiss_review_request_for_invalid_pr():
"label": "python:3.6"
},
"base": {
"label": "python:master"
"label": "python:main"
},
"requested_reviewers": [
{
Expand Down Expand Up @@ -246,7 +246,7 @@ async def test_valid_pr_review_request_not_dismissed():
"label": "someuser:bpo-3.6"
},
"base": {
"label": "python:master"
"label": "python:main"
},
"requested_reviewers": [
{
Expand Down

0 comments on commit c895997

Please sign in to comment.