Enforce naming convention on MR title (GA)
### Problem to solve
At the moment I can not enforce any naming rules on a MR name. I would like to control the naming convention of a MR because it is hard to tell any new contributor (OpenSource or Enterprise) to follow your naming conventions (based on wiki or whatever, maybe that change from repo to repo). An auto blocking feature would solve that very easy and nice, so that the contributor get fast feedback on wrong naming.
1. Ensuring the right commit message is used
- **Potential alternative solution** - https://gitlab.com/gitlab-org/gitlab/-/work_items/588095+
- _We'd want to have a naming convention applied in the Merge Request title instead of enforcing rules on commit messages. We want Jira/GitLab issues number mentioned in the MR title as a prefix_ https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_968029174
- _It's painful trying to enforce conventional commit style MR titles_ https://gitlab.com/gitlab-org/gitlab/-/issues/16080#note_1901718292 https://gitlab.com/gitlab-org/gitlab/-/issues/16080#note_2030257530
- Follow conventional commits naming since the merge request title is used as commit message when squashing https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1425426523 https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_2374836399
1. Linking the merge request to a work item
- _a mandatory JIRA ticket needs to be associated with the merge request to be able to submit the merge request_ https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1165682519
- _be in compliance with various standards, such as SOX and SOC 2. The goal is to enforce that any merge requests submitted to projects in our GitLab have an associated Jira issue, and to include that Jira issue number as part of the MR title._ https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1692855081
1. Downstream systems
- _useful for exporting to spreadsheets_ https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1713295595
- _Our tools rely on well-formated MR titles_ https://gitlab.com/gitlab-org/gitlab/-/issues/16080#note_1874424657
#### Other requests for merge request titles rules
1. Branch name: "The very common approach is to define MR name as a branch name" https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1834653054
- https://gitlab.com/gitlab-org/gitlab/-/work_items/16080+
3. Empty default name
- https://gitlab.com/gitlab-org/gitlab/-/work_items/27540+
- _Sometimes the title of the MR is the last commit message, sometimes it's the dreaded "Resolve ..."_ https://gitlab.com/gitlab-org/gitlab/-/issues/16080#note_2581591353
### Current workarounds users are doing to get around this problem
1. Manual check
- https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1136636117
- https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1692855081
3. Using a pipeline job to check the name of the merge request
- Cons:
- The workaround job costs additional resources to run https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1557456918
- The problem is that it's only done when the pipeline runs. When the MR title is changed, pipeline won't run. https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1425629295
* MR is opened
* Pipeline ran and validated the MR title (it meets the requirements)
* Someone decided to change the MR title because maybe it wasn't accurate enough previously
* After the MR title change, there's no new pipeline and so there isn't a re-validation of the pipeline
* If the MR was already approved, there's nothing preventing the MR from merging even though it doesn't meet the convention/requirements.
### Other potential solutions
1. Improve JIRA integration https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1692898868 and recommend usage of "Require associated Jira issue for merge requests to be merged". https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1713231548
- A reason why linking doesn't always work because the validation is enforced at time of merge, only half of the opened MRs in this scenario are linked to the ticket, producing metrics that suggest the engineer was moving at half the pace they actually were. The metrics will also lack reporting on wasted effort in the form of closed MRs.
1. Add requirement to have work item associated with merge request. This would allow for extraction of work item to be used as variables for naming convention.
### Proposal
Simple regex enforcement would more than satisfy my needs as someone on the list of users that need this for Jira purposes. https://gitlab.com/gitlab-org/gitlab/-/issues/25689#note_1693144293
1. Merge check for title
2. Setting for enforcing title (likely some kind of regex field)
3. API support for configuring this field
4. UI for merge request creation/edit
### What does success look like, and how can we measure that?
Monitor the adoption of the feature
epic