Merge request with multiple commits causes JIRA integration to break unless modified
Summary
When a merge request is created, Gitlab does its best to automatically fill in the 'title' field based on the branch it is merging from. It appears that if a single commit is present on the branch, it takes the commit message from that commit as the auto-populated title for that merge request. This is normally fine for JIRA integration as typically the commit message will reference the JIRA issue key.
However, if there are multiple commits on the branch, Gitlab uses a modification of the branch name as the title, which will not be picked up by the JIRA integration.
Steps to reproduce
N.B. Jira integration is not required to reproduce this issue
- Create a feature branch in a Gitlab project. Ensure the branch name is in the format of a JIRA issue key (e.g. TEST-343)
- Make at least two commits
- Create a merge request
What is the current bug behavior?
With multiple commits, it appears that the default title of the merge request is supposed to take the branch name, however it does not take the exact branch name, instead it takes a modification of the branch name. To be specific, it seems to convert the branch name to sentence-case, and replaces the dash with a space, for example: "Test 343"
This means that when the merge request is created using this string as its title, JIRA integration will fail as it is looking for merge requests titles containing a JIRA issue id (i.e. with a dash). The Jira ticket will therefore not be updated with a link to the corresponding merge request.
What is the expected correct behavior?
The branch name used for the title should not be modified by Gitlab
Workaround
The current workaround is that I have to ensure that everyone in my team manually modifies the merge request name to convert the JIRA issue key reference into its correct format.
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 16.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.3.3p222 Gem Version: 2.6.6 Bundler Version:1.13.7 Rake Version: 10.5.0 Redis Version: 3.2.5 Git Version: 2.10.2 Sidekiq Version:4.2.7GitLab information Version: 9.0.4-ee Revision: 349b042 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.1 URL: https://gitlab HTTP Clone URL: https://gitlab/some-group/some-project.git SSH Clone URL: git@gitlab:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: no
GitLab Shell Version: 5.0.0 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/ Git: /opt/gitlab/embedded/bin/git
Possible fixes
- Prevent Gitlab from modifying the branch name when using it as a title in a merge request and/or
- Allow merge request titles to be validated against a regular expression to force JIRA issue ids to be specified