-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add branchName autolinks #3644
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
Add branchName autolinks #3644
Conversation
cc07324
to
9787ec2
Compare
9787ec2
to
333f056
Compare
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my own learning/benefit, can you explain how you formulated this regex?
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.
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
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.
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.
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
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.
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 <[email protected]>
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