Jira issue regex false positive TICKET-1234-56
Summary
With Jira integration enabled, we get false positive matches for Jira issues when we reference our companies' not-Jira customer support tickets which are in the format TICKET-[0-9]+-[0-9]+.
The currently used regex does not
Steps to reproduce
- enable jira integration
- commit a change with TICKET-12345-455 in the commit msg
- observe the result in gitlab: TICKET-12345-455
Example Project
I've setup an example project: https://gitlab.com/twouters/jira-tickets
relevant commit example twouters/jira-tickets@dfa10f10
What is the current bug behavior?
Jira issue detection is too broad for our usecase.
What is the expected correct behavior?
Jira issue detection could be a bit stricter.
Relevant logs and/or screenshots
N/A
Output of checks
This bug happens on GitLab.com
Possible fixes
- https://gitlab.com/gitlab-org/gitlab-foss/-/blob/7484851b5f762fad81ddecb4735d22828e205af1/app/models/project_services/jira_service.rb#L59
- https://gitlab.com/gitlab-org/gitlab-foss/-/blob/7484851b5f762fad81ddecb4735d22828e205af1/lib/gitlab/regex.rb#L354
The current regex being used is [A-Z][A-Z_0-9]+-\d+
, so a possible fix could be to change the issue detection to /(?<issue>\b#{Gitlab::Regex.jira_issue_key_regex}(?!-)\b)/
which requires the Jira issue to end on any word boundary except '-'.
Edited by Arturo Herrero