Skip to content

Commit 334c817

Browse files
zwaremaxking
andauthored
Use GH: rather than @ to tag core devs in Automerge-Triggered-By (#405)
* Use GH to signify Github handle of the user instead of "@". "@" usually doesn't give any information about what exactly the handle means since we don't know it is a Github handle from the commit message. Changing the pattern to be `GH:` similar to what we do for Pull Requests with (GH-). Fixes #270 * Handle removing GH:-style Automerge-Triggered-By ...when automerge label is removed by a core-dev. Co-authored-by: Abhilash Raj <[email protected]>
1 parent 4e964a7 commit 334c817

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

miss_islington/status_change.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def pr_unlabeled(event, gh, *args, **kwargs):
8383

8484
body = event.data["pull_request"]["body"]
8585
url = event.data["pull_request"]["url"]
86-
new_body = re.sub(rf"{AUTOMERGE_TRAILER}: @(\w|\-)+", "", body)
86+
new_body = re.sub(rf"{AUTOMERGE_TRAILER}: (GH:|@)(\w|\-)+", "", body).rstrip()
8787
await gh.patch(url, data={"body": new_body})
8888

8989

@@ -178,5 +178,5 @@ async def merge_pr(gh, pr, sha, is_automerge=False):
178178

179179

180180
async def add_automerged_by(gh, pr_data, username):
181-
new_pr_body = f"{pr_data['body']}\n\n{AUTOMERGE_TRAILER}: @{username}"
181+
new_pr_body = f"{pr_data['body'].rstrip()}\n\n{AUTOMERGE_TRAILER}: GH:{username}"
182182
await gh.patch(pr_data["url"], data={"body": new_pr_body})

tests/test_status_change.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ async def test_automerge_label_triggered_by_added_to_pr():
18011801
await status_change.router.dispatch(event, gh)
18021802
assert gh.patch_url == f'{data["pull_request"]["url"]}'
18031803
assert gh.patch_data == {
1804-
"body": f"{data['pull_request']['body']}\n\nAutomerge-Triggered-By: @Mariatta"
1804+
"body": f"{data['pull_request']['body']}\n\nAutomerge-Triggered-By: GH:Mariatta"
18051805
}
18061806

18071807

@@ -1815,7 +1815,7 @@ async def test_automerge_label_removed_by_core_dev():
18151815
"head": {"sha": sha},
18161816
"number": 5547,
18171817
"title": "bpo-32720: Fixed the replacement field grammar documentation.",
1818-
"body": "\n\n`arg_name` and `element_index` are defined as `digit`+ instead of `integer`.\n\nAutomerge-Triggered-By: @miss-islington",
1818+
"body": "\n\n`arg_name` and `element_index` are defined as `digit`+ instead of `integer`.\n\nAutomerge-Triggered-By: GH:miss-islington\n\nAutomerge-Triggered-By: @miss-islington",
18191819
"url": "https://github.com/api/repos/python/cpython/pulls/5547",
18201820
"issue_url": "https://github.com/api/repos/python/cpython/issues/5547",
18211821
},
@@ -1854,6 +1854,8 @@ async def test_automerge_label_removed_by_core_dev():
18541854
await status_change.router.dispatch(event, gh)
18551855
assert "body" in gh.patch_data
18561856
assert "Automerge-Triggered-By: @miss-islington" not in gh.patch_data["body"]
1857+
assert "Automerge-Triggered-By: GH:miss-islington" not in gh.patch_data["body"]
1858+
assert gh.patch_data["body"].endswith("`integer`.")
18571859

18581860

18591861
async def test_automerge_label_removed_by_non_core_dev():

0 commit comments

Comments
 (0)