Adds support for regex in autolinks
Description
Adds support for autolink references based on regular expression for more advanced use cases, while keeping backwards compatibily with the existing prefix-based cases.
Additionally, it refactors the Gerrit autolinks to leverage the new option:

- Closes #1903
- Closes #1314
- Closes #1121
- Fixes #2251
Checklist
- [x] I have followed the guidelines in the Contributing document
- [x] My changes follow the coding style of this project
- [x] My changes build without any errors or warnings
- [x] My changes have been formatted and linted
- [x] My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
- [x] My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
- [x] My changes have a descriptive commit message with a short title, including a
Fixes $XXX -orCloses #XXX -prefix to auto-close the issue that your PR addresses
Extras:
- [ ] Make changes to the embedded settings browser (help welcome)
- [ ] Properly handle escaped markdown (and probably HTML) matching
Update: we can probably use regexp-tree to parse the regex and escape it properly for markdown and html.
Ok, this is now working. The implementation may be a little rough though.
You can test with the following repo:
git clone https://review.gerrithub.io/felipecrs/gerrit-jenkins
And the last commit. It comes with a settings.json like:
{
"gitlens.autolinks": [
{
"regex": "(JENKINS-[0-9]+)",
"url": "https://issues.jenkins.io/browse/<num>"
}
]
}
Demo:
https://user-images.githubusercontent.com/29582865/203101574-d11f2d46-f00b-48e2-aa06-66de52558f65.mp4
This would be awesome and open up matching on JIRA ticket ids in branch names, ex: feat_proj_123
@eamodio, any chance to get that merged? I just wanted to configure Gitlens once for all Jira projecs as well and was surprised that this was not working. I mentioned you, since you originally suggested to provide a PR here: https://github.com/gitkraken/vscode-gitlens/issues/1314#issuecomment-757370056 which @felipecrs already seems to have solved.
Could we clarify what changes must be made to this implementation in order to get it merged (other than resolving conflicts)? Is the added dependency a dealbreaker, or could it be acceptable as an interim solution? Would love to see this functionality hit main!
Seems like this issue, plus #1903, and #1314 would be solved by implementing this PR. Maybe an easy rebase + conflict resolution could result in hitting multiple bugs with one stone (😅 er... Pull Request).
In the VSCode Extension's current state, it's impossible to get autolinks working for any issue tracker that doesn't follow a simple PREFIX-<num> and URL pattern. That includes linking to issues on GitHub, GitLab, SourceHut, and probably many others. Seems that this feature was initially tied to JIRA and Atlassian products only, rendering autolinks useless for most other platforms.
PS: I can rebase and resolve conflicts upon some maintainer green light.
Will this PR be merged in the future?