Skip to content

Commit 7647ace

Browse files
committed
Merge #130: github-merge: Handle deleted users gracefully
8b7b630 github-merge: Handle deleted users gracefully (laanwj) Pull request description: Handle deleted github users gracefully when retrieving ACKs by replacing their name with `[deleted]` in the sanitization function. Tested with bitcoin/bitcoin#15423. ACKs for top commit: MarcoFalke: cr ACK 8b7b630 Tree-SHA512: 21aa715e4d3196bcde6a8523892afd415c8aae4a440e9ea413a5459ce8c0c978747289a3300e4ff28647cb6af8aded59fd749a06d48b5c2b09896e3eee48d6c1
2 parents b5fabbc + 8b7b630 commit 7647ace

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

github-merge.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ def sanitize_ghdata(rec):
8585
rec['body'] = ''
8686
rec['body'] = sanitize(rec['body'], newlines=True)
8787

88-
# "Github username may only contain alphanumeric characters or hyphens'.
89-
# Use \Z instead of $ to not match final newline only end of string.
90-
if not re.match('[a-zA-Z0-9-]+\Z', rec['user']['login'], re.DOTALL):
91-
raise ValueError('Github username contains invalid characters: {}'.format(sanitize(rec['user']['login'])))
88+
if rec['user'] is None: # User deleted account
89+
rec['user'] = {'login': '[deleted]'}
90+
else:
91+
# "Github username may only contain alphanumeric characters or hyphens'.
92+
# 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+
raise ValueError('Github username contains invalid characters: {}'.format(sanitize(rec['user']['login'])))
9295
return rec
9396

9497
def retrieve_json(req_url, ghtoken, use_pagination=False):

0 commit comments

Comments
 (0)