graydon/bors — pull request #39 by nathantypanski (2014-07-16 21:45:00+00:00)
Title: allow hyphens in usernames

Previously, GitHub usernames containing hyphens were broken: if a
hyphenated username were provided in a `r=some-body` request to bors,
bors would interpret that request as `r=some`.

The reason for this is the regex parsing the username in those comments
was only looking for a word (`\w+`, or equivalently `[a-zA-Z0-9_]+`),
and words end at hyphens.

This changes those regular expressions to look for any of the word
characters and additionally a hyphen character (`[a-zA-Z0-9-_]+`).

I am not able to test this in production (I don't have the configuration)
but my experiments at the interpreter suggest this regex is correct for
parsing usernames with hyphens.

>>> import re
>>> c = 'r=chris-morgan'
>>> [m.group(1)
for m in [re.match(r"r=([a-zA-Z0-9_-]+)", c)]
if m]
['chris-morgan']
>>> s = 'r=chris-morgan b2f6b40'
>>> [m.group(1)
for m in [re.match(r"r=([a-zA-Z0-9_-]+) ([a-z0-9]+)", s)]
if m]
['chris-morgan']

But if anyone has a good clue how to check if this works, let me know.

Closes #38.