-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally link all apparent changeset references to BitBucket #102
Conversation
Related to #51. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code implementation looks solid.
A design question:
Does bitbucket use short sha's or only ever full sha's...? Ie, should we do a two-pass filter of "regex looks like" followed by something like https://stackoverflow.com/a/32234251/770425 to verify it actually is a sha?
If there are valid scenarios where sha's are abbreviated in the issues, then I'm +1 on this. I know GitHub abbreviates them, just not sure if Bitbucket does...
return ' [{sha} (bb)](https://bitbucket.org/{repo}/commits/{sha})'.format( | ||
repo=options.bitbucket_repo, sha=sha, | ||
) | ||
content = re.sub(r" ([a-f0-9]{6,40})\b", replace_changeset, content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
been a while since I worked with regex's... what does the {6,40}
here do? Is it replacing characters 6 through 40, or inspecting characters 6-40 or only matching strings of length 6-40?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[a-f0-9]{6,40}
means 6 to 40 hex characters. This is looking for a hex string between 6 and 40 characters long, preceded by a space, and ending at a word boundary. Without the space, there were some false positives, but this seemed to work well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to improve the heuristic by insisting that if the sha was shorter than 8 characters, it had to have a digit in it, so that English words wouldn't get linked.
nudge @nedbat can you answer my question about short sha's? like to get this merged if they are a realistic thing... |
I've used short sha's in my own comments on tickets, which is why I wanted to include them. I will respond to a ticket, "Fixed in ab3de1cd". |
LGTM, thanks! |
No description provided.