Skip to content

Commit

Permalink
Ignore case when matching backport PR title (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariatta authored Jun 30, 2022
1 parent e4e1eac commit a20390b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bedevere/backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

router = gidgethub.routing.Router()

TITLE_RE = re.compile(r'\s*\[(?P<branch>\d+\.\d+)\].+\((?:GH-|#)(?P<pr>\d+)\)')
TITLE_RE = re.compile(r'\s*\[(?P<branch>\d+\.\d+)\].+\((?:GH-|#)(?P<pr>\d+)\)', re.IGNORECASE)
MAINTENANCE_BRANCH_TITLE_RE = re.compile(r'\s*\[(?P<branch>\d+\.\d+)\].+')
MAINTENANCE_BRANCH_RE = re.compile(r'\s*(?P<branch>\d+\.\d+)')
BACKPORT_LABEL = 'needs backport to {branch}'
Expand Down
20 changes: 12 additions & 8 deletions tests/test_backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ async def test_missing_backport_label():
assert gh.delete_url is None


async def test_backport_label_removal_success():
@pytest.mark.parametrize('pr_prefix', ['GH', 'gh'])
async def test_backport_label_removal_success(pr_prefix):
event_data = {
'action': 'opened',
'number': 2248,
'pull_request': {
'title': '[3.6] Backport this …',
'body': '…(GH-1234)',
'body': f'…({pr_prefix}-1234)',
'issue_url': 'https://api.github.com/issue/2248',
'base': {
'ref': '3.6',
Expand Down Expand Up @@ -149,12 +150,13 @@ async def test_backport_label_removal_success():
assert expected_post is not None


async def test_backport_label_removal_with_leading_space_in_title():
@pytest.mark.parametrize('pr_prefix', ['GH', 'gh'])
async def test_backport_label_removal_with_leading_space_in_title(pr_prefix):
event_data = {
'action': 'opened',
'number': 2248,
'pull_request': {
'title': ' [3.6] Backport this (GH-1234)',
'title': f' [3.6] Backport this ({pr_prefix}-1234)',
'body': '…',
'issue_url': 'https://api.github.com/issue/2248',
'base': {
Expand Down Expand Up @@ -183,12 +185,13 @@ async def test_backport_label_removal_with_leading_space_in_title():
{'name': 'needs backport to 3.6'})


async def test_backport_label_removal_with_parentheses_in_title():
@pytest.mark.parametrize('pr_prefix', ['GH', 'gh'])
async def test_backport_label_removal_with_parentheses_in_title(pr_prefix):
event_data = {
'action': 'opened',
'number': 2248,
'pull_request': {
'title': '[3.6] Backport (0.9.6) this (more bpo-1234) (GH-1234)',
'title': f'[3.6] Backport (0.9.6) this (more bpo-1234) ({pr_prefix}-1234)',
'body': '…',
'issue_url': 'https://api.github.com/issue/2248',
'base': {
Expand Down Expand Up @@ -217,12 +220,13 @@ async def test_backport_label_removal_with_parentheses_in_title():
{'name': 'needs backport to 3.6'})


async def test_label_copying():
@pytest.mark.parametrize('pr_prefix', ['GH', 'gh'])
async def test_label_copying(pr_prefix):
event_data = {
'action': 'opened',
'number': 2248,
'pull_request': {
'title': '[3.6] Backport this (GH-1234)',
'title': f'[3.6] Backport this ({pr_prefix}-1234)',
'body': 'N/A',
'issue_url': 'https://api.github.com/issue/2248',
'base': {
Expand Down

0 comments on commit a20390b

Please sign in to comment.