Skip to content
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

Merged
merged 2 commits into from
Jun 25, 2018

Conversation

nedbat
Copy link
Contributor

@nedbat nedbat commented May 28, 2018

No description provided.

@nedbat
Copy link
Contributor Author

nedbat commented May 28, 2018

Related to #51.

Copy link
Owner

@jeffwidman jeffwidman left a 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)
Copy link
Owner

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?

Copy link
Contributor Author

@nedbat nedbat Jun 2, 2018

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.

Copy link
Contributor Author

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.

@jeffwidman
Copy link
Owner

nudge @nedbat can you answer my question about short sha's?

like to get this merged if they are a realistic thing...

@nedbat
Copy link
Contributor Author

nedbat commented Jun 2, 2018

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".

@jeffwidman
Copy link
Owner

LGTM, thanks!

@jeffwidman jeffwidman merged commit fb25e43 into jeffwidman:master Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants