Merge requests
Templates and default title
4 min read
Projects often have a template for the merge request description: a checklist, the "What changes"
and "How to test" sections, the issue it closes. In the Create merge request form, the
Template selector brings the project's templates, and the default template comes already
applied. The GitLab variables (%{all_commits}, %{closes_issue}…) are filled in by Versora
itself, because the MR creation API doesn't do that. With the project's title template (GitLab
19.0), the title also comes ready.
- Create merge request form › Template line, between the title and the description.
The line only appears when the project has a template, or when reading them failed.
| Service | Source |
|---|---|
| GitLab | The project's merge request templates (.gitlab/merge_request_templates/ folder), including those inherited from the group and the instance, and the default text from the project settings (merge request template in the settings, a Premium feature). |
| GitHub | The repository's pull_request_template.md and the files in the PULL_REQUEST_TEMPLATE/ folder. |
| Option | What it does |
|---|---|
| None (text from commits) | Goes back to the text suggested by the commits and the branch's issue. |
| Project default (settings) | GitLab only, when the project has the default text in its settings. |
| Each template, by name | Replaces the description with the template's content, with the variables filled in. |
Name (default) | The template that applies by default: the text from the project settings or Default.md on GitLab (case-insensitive); the single template on GitHub. |
- Open the creation form (see Create merge request).
- If the project has a default template, the description comes with it already applied.
- To use another one, choose it in Template. While the content is read, you see "Reading the template…".
- If you had already written something in the description, the app asks first (see below).
- Adjust the text and create the MR.
Choosing another template after editing the description opens the Replace the description? dialog: "What you wrote in the description will be replaced by "Bugfix"." Replace applies the template; Cancel keeps your text. If you haven't touched the description, the change is immediate.
When the template doesn't mention the issue and the suggested description had Closes #123 (from
the branch's issue), that line stays at the end of the text.
GitLab allows variables in the template, filled in when the MR is created from the web page. Through the API that doesn't happen, so Versora fills them in before sending, with the commits from the local repository:
| Variable | Becomes |
|---|---|
%{source_branch} | The source branch, for example feature/login. |
%{target_branch} | The target branch, for example main. |
%{all_commits} | The messages of the MR's commits (up to 100, without merge commits), each one starting with * and separated by a blank line. Very long messages go in with just the title. |
%{first_commit} | The full message of the MR's oldest commit. |
%{first_multiline_commit} | The message of the oldest commit that has a body; with none, the title that is in the form. |
%{first_multiline_commit_description} | Just the body of that commit. |
%{co_authored_by} | One Co-authored-by: Name <email> line per commit author, without repeats and without you. |
%{closes_issue} | Closes #123, when the branch name starts with the issue number, the way GitLab creates it (123-corrige-login). A branch like feature/123-… doesn't count. |
The title variables (below) also work inside the template. A variable the app doesn't know stays in the text as written. GitHub has no variables of its own, but a GitHub template that uses these variables is also filled in by the app.
In GitLab 19.0, the project can have a title template for merge requests. When it does, the form comes with the title already assembled and shows the line "Title from the project template:" with the template.
| Title variable | Becomes |
|---|---|
%{source_branch} | The source branch. |
%{target_branch} | The target branch. |
%{title_from_branch} | The branch name as a sentence: hyphens and underscores become spaces, only the first letter capitalized (corrige-login_mobile → Corrige login mobile). |
%{first_commit_title} | The title of the MR's first commit. |
%{issue_id} | The issue number at the start of the branch name (123-…). |
%{issue_title} | That issue's title on GitLab (the app only queries the server when the template uses the variable). |
The title you type takes precedence over the template: after you edit the field, the template doesn't replace it.
To fill in the variables, the app reads the MR's commits in the local repository (up to 100), between the target and the branch:
git log --max-count=100 origin/main..feature/login
The templates are read through the server API (GitLab: the project's merge request templates; GitHub: the repository's templates). Nothing is written to the repository.
Nothing to undo: the template only changes the form's text. To go back to the text from the commits, choose None (text from commits).
- "Couldn't read the GitLab templates; the form works without them.": reading failed (network, permission). Hover over the notice to see the reason; the form works normally.
- "The "Bugfix" template no longer exists in the project.": the template was removed after the list was read. Close the form and open it again.
- The form waits for the project defaults for up to 5 seconds. With a slow server, it goes on with the text from the commits; the selector is still available when the list arrives.
There's no dedicated preference: the templates and the title template belong to the project, on the server. The template list is cached for 5 minutes.
- Create merge request
- Branch issue and reference in the commit
- Create issue (which also uses templates)