Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Update Issue Linker regex to only include issues from the same repo #12623

Closed
jonalmeida opened this issue Aug 9, 2022 · 0 comments · Fixed by #12624
Closed

Update Issue Linker regex to only include issues from the same repo #12623

jonalmeida opened this issue Aug 9, 2022 · 0 comments · Fixed by #12624
Assignees
Labels
automation Build automation, Continuous integration, ..
Milestone

Comments

@jonalmeida
Copy link
Contributor

jonalmeida commented Aug 9, 2022

We're using a simple regex here for grabbing the linked issue that will find any issue ID, regardless of repo:

commit-regexp: "#(\\d+)+"

We can update this to only link an ID when it's not part of the same repo. The below expression translates to: do not match if the preceding token is a string value.

(?<![A-Za-z\-\_]+)#(\d+)+

Regex evaluator with tests: https://regexr.com/6rg2v

┆Issue is synchronized with this Jira Task

@jonalmeida jonalmeida added the automation Build automation, Continuous integration, .. label Aug 9, 2022
@jonalmeida jonalmeida self-assigned this Aug 9, 2022
jonalmeida added a commit to jonalmeida/android-components that referenced this issue Aug 9, 2022
…r characters

To avoid matching against issues in other repositories, we can reduce
our matches to not include values if they are preceded by 1 or more
string/number/hypen/underscore values.

Tested using:
 - a JS console:
 ```javascript
 const issueRegExp = new RegExp("(?<![A-Za-z\\-\\_]+)#(\\d+)+", "g");
 const numMatches = Array.from(issueRegExp[Symbol.matchAll]("mozilla-mobile#12345")).length
 const numMatches2 = Array.from(issueRegExp[Symbol.matchAll](" mozilla-mobile#12345 ")).length

 assert(numMatches == 0);
 assert(numMatches2 == 1);
 ```
 - regex tester: https://regexr.com/6rg2v
@mergify mergify bot closed this as completed in #12624 Oct 11, 2022
mergify bot pushed a commit that referenced this issue Oct 11, 2022
To avoid matching against issues in other repositories, we can reduce
our matches to not include values if they are preceded by 1 or more
string/number/hypen/underscore values.

Tested using:
 - a JS console:
 ```javascript
 const issueRegExp = new RegExp("(?<![A-Za-z\\-\\_]+)#(\\d+)+", "g");
 const numMatches = Array.from(issueRegExp[Symbol.matchAll]("#12345")).length
 const numMatches2 = Array.from(issueRegExp[Symbol.matchAll](" #12345 ")).length

 assert(numMatches == 0);
 assert(numMatches2 == 1);
 ```
 - regex tester: https://regexr.com/6rg2v
@github-actions github-actions bot added this to the 107.0.0 🍂 milestone Oct 11, 2022
JohanLorenzo pushed a commit to mozilla-mobile/firefox-android that referenced this issue Oct 13, 2022
…tch issue ID if preceded by other characters

To avoid matching against issues in other repositories, we can reduce
our matches to not include values if they are preceded by 1 or more
string/number/hypen/underscore values.

Tested using:
 - a JS console:
 ```javascript
 const issueRegExp = new RegExp("(?<![A-Za-z\\-\\_]+)#(\\d+)+", "g");
 const numMatches = Array.from(issueRegExp[Symbol.matchAll]("https://github.com/mozilla-mobile/android-components/issues/12345")).length
 const numMatches2 = Array.from(issueRegExp[Symbol.matchAll](" mozilla-mobile/android-components#12345 ")).length

 assert(numMatches == 0);
 assert(numMatches2 == 1);
 ```
 - regex tester: https://regexr.com/6rg2v
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automation Build automation, Continuous integration, ..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant