Conversation
cc07324 to
9787ec2
Compare
9787ec2 to
333f056
Compare
There was a problem hiding this comment.
Gave this a test run and timed it, on a few example branches in the vscode-gitlens repo with several integrations connected (GitHub, GitLab, Jira) and it performed pretty well in my experience. Some comments and questions below from examining the code.
Also, please rebase this on the latest main when you can. There are conflicts to resolve.
| ref.branchNameRegex = new RegExp( | ||
| `(^|\\-|_|\\.|\\/)(?<prefix>${ref.prefix})(?<issueKeyNumber>${ | ||
| ref.alphanumeric ? '\\w' : '\\d' | ||
| }+)(?=$|\\-|_|\\.|\\/)`, | ||
| 'gi', | ||
| ); |
There was a problem hiding this comment.
Just for my own learning/benefit, can you explain how you formulated this regex?
There was a problem hiding this comment.
There's an easy regex playground service called https://regex101.com/, I always test the regexes there before I put them to the code.
Speaking about the current regex, here I expect that the link is wrapped between any star/end (split) symbols (expecting one of [-,_,.,/]). The both start/end symbols are the same except of regex symbols ^ and $. Then I expect that the issue key is a concatenation of the prefix and some non-zero count (+) of numbers (\d) or alphanumeric (\w)
333f056 to
a76a6a2
Compare
ramin-t
left a comment
There was a problem hiding this comment.
Bug/regression: branch autolink regexes are being applied to commit messages, which is not what we want. For example, a simple number in my commit message was picked up as an issue:
Since you're out, I will fix it - seems like as I suggested before, we need to check referenceType in _getAutolinks like we do in _getBranchAutolinks
ramin-t
left a comment
There was a problem hiding this comment.
Limited testing on this but it seems to perform well, and the regression with commit messages appears to be fixed.
* Add branchName autolinks * update changelog * Fix review notes * Fixes comment, fixes commit message autolinks, makes index optional * Fixes spacing --------- Co-authored-by: Ramin Tadayon <ramin.tadayon@gitkraken.com>

Description
Adds getBranchAutolinks method to Autolinks class
Adds a few tests for autolinks
Checklist
Fixes $XXX -orCloses #XXX -prefix to auto-close the issue that your PR addresses