Auto linking Jira issues on MRs with multiple commits doesn't work when the branch name contains a Jira key with certain trailing characters
Summary
When an MR with multiple commits is created on a project with Jira integration enabled, the MR title will auto link the Jira issue if a Jira key is found on the branch name. But if the branch name contains a Jira key with certain trailing characters, auto linking won't work. For example : branch name feature/JIRA-1234-some_tag
works where feature/JIRA-1234_some_tag
doesn't work.
Steps to reproduce
Firstly, enable Jira integration on a project. Then,
Works :
- Create a branch
feature/JIRA-1234-some_tag
. - Push two commits to it.
- Create an MR from
feature/JIRA-1234-some_tag
tomaster
.
Doesn't work :
- Create a branch
feature/JIRA-1234_some_tag
. - Push two commits to it.
- Create an MR from
feature/JIRA-1234_some_tag
tomaster
.
Example Project
This behaviour is reproducible on GitLab.com. Please check out the example MRs here : MR1 works but MR2 doesn't.
What is the current bug behavior?
While creating an MR with multiple commits, if the branch name contains a Jira key with certain trailing characters, auto linking won't work. For example : branch name feature/JIRA-1234-some_tag
works where feature/JIRA-1234_some_tag
doesn't work.
What is the expected correct behavior?
Auto linking should work if there's a valid Jira key on the branch name. If there are any illegal trailing characters on the Jira key, those should be discarded and a link must be created to the valid Jira issue.
Relevant logs and/or screenshots
Not required. Please check out the example MRs here.
Output of checks
NA.
Results of GitLab environment info
root@gitlab-ee-12-9-2:~# sudo gitlab-rake gitlab:env:info
System information
System: Ubuntu 16.04
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.6.5p114
Gem Version: 2.7.10
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 5.0.7
Git Version: 2.24.1
Sidekiq Version:5.2.7
Go Version: unknown
GitLab information
Version: 12.9.2-ee
Revision: 0ad76f4d374
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 10.12
URL: http://gitlab.example.com
HTTP Clone URL: http://gitlab.example.com/some-group/some-project.git
SSH Clone URL: git@gitlab.example.com:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 12.0.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
root@gitlab-ee-12-9-2:~# sudo gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 12.0.0 ? ... OK (12.0.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: OK
Redis available via internal API: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet)
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ...
1/1 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.5.3 ? ... yes (2.6.5)
Git version >= 2.22.0 ? ... yes (2.24.1)
Git user has default SSH configuration? ... yes
Active users: ... 1
Is authorized keys file accessible? ... yes
Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
Looks like this MR introduced the bug.