doc/user/project/merge_requests/title_validation.md
{{< details >}}
{{< /details >}}
{{< history >}}
merge_request_title_regex. Disabled by default.merge_request_title_regex removed.{{< /history >}}
You can enforce a naming convention on merge request titles by matching them against a RE2 regular expression pattern. When you configure a title pattern for a project, merge requests with titles that do not match the pattern are blocked from merging.
Use title validation to:
Configure a regex pattern that all merge request titles in the project must match before they can be merged.
Prerequisites:
To configure title validation:
When you set a Title pattern, the Title example is also required. The Title example is visible to users when their merge request title does not match the pattern.
To remove title validation, clear both the Title pattern and Title example text boxes, then select Save changes.
To configure title validation with the API, you can also use the projects API.
Title validation uses RE2 syntax, not PCRE. RE2 does not support backreferences or lookahead/lookbehind assertions.
The pattern and description fields each have a maximum length of 255 characters.
The following are regex pattern examples:
Jira ticket reference (example valid title: PROJ-123 Fix login bug):
^[A-Z]+-\d+ .+
Conventional commits (example valid title: feat(auth): add SSO support):
^(feat|fix|docs|chore|refactor|test|style)(\(.+\))?: .+
Custom prefix (example valid title: BUGFIX: resolve timeout error):
^(FEATURE|BUGFIX|HOTFIX): .+
Bracketed category (example valid title: [Feature] Add dark mode):
^\[.+\] .+
When a title validation pattern is configured:
If a merge request is blocked by title validation:
Title validation applies to the full title string, including any Draft:
prefix. If your regex pattern does not account for the Draft: prefix,
draft merge requests might fail validation. Consider using a pattern like
^(Draft: )?YOUR_PATTERN to allow both draft and non-draft titles.
Title validation uses RE2 syntax, which differs from PCRE syntax used by many online regex testers. To verify your pattern: