Skip to content

Commit a65a970

Browse files
committed
Merge #127: Handle GitHub bots that have invalid characters in their username
ece77f7 Handle GitHub bots that have invalid characters in their username (Alekos Filini) Pull request description: I tried merging a PR that had a codecov comment with the new code coverage, and `github-merge.py` failed with: ``` Warning: unable to retrieve pull information from github: Github username contains invalid characters: codecov[bot] Traceback (most recent call last): File "/home/user/Developer/bitcoin-maintainer-tools//github-merge.py", line 480, in <module> main() File "/home/user/Developer/bitcoin-maintainer-tools//github-merge.py", line 429, in main comments = retrieve_pr_comments(repo_from,pull,ghtoken) + retrieve_pr_reviews(repo_from,pull,ghtoken) TypeError: unsupported operand type(s) for +: 'NoneType' and 'list' ``` I thought it would have been more conservative to just explicitly remove the `[bot]` suffix rather than adding square brackets to the regex. Top commit has no ACKs. Tree-SHA512: a617cec72ef9427f798e8c88f7c0873b46a2145e9f11620428de098241aefc7818a873efb5345dc659c6652bc55ee1b5dc6a72edb5fe72ac973d1a2ae60dda2b
2 parents 030c516 + ece77f7 commit a65a970

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

github-merge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ def sanitize_ghdata(rec):
8989
rec['user'] = {'login': '[deleted]'}
9090
else:
9191
# "Github username may only contain alphanumeric characters or hyphens'.
92+
# Sometimes bot have a "[bot]" suffix in the login, so we also match for that
9293
# Use \Z instead of $ to not match final newline only end of string.
93-
if not re.match('[a-zA-Z0-9-]+\Z', rec['user']['login'], re.DOTALL):
94+
if not re.match('[a-zA-Z0-9-]+(\[bot\])?\Z', rec['user']['login'], re.DOTALL):
9495
raise ValueError('Github username contains invalid characters: {}'.format(sanitize(rec['user']['login'])))
9596
return rec
9697

0 commit comments

Comments
 (0)