Add MR title template logic to BuildService and MessageGenerator (Part 2/4)
Summary
Part 2 of 4 for customizable MR title templates.
Adds the core backend logic: template application in BuildService and placeholder rendering in MessageGenerator.
What does this MR do?
- Gates template application behind
mr_default_title_templatefeature flag (project actor) - Adds
new_mr_titlemethod toMessageGeneratorwith allowlisted placeholders - Adds
title_from_branchplaceholder variable - Extracts
mr_title_template_enabled?predicate for readability - Moves
humanize_branch_nametoMessageGeneratoras a shared class method - Memoizes
MessageGeneratorviastrong_memoize(shared between title and description generation) - Truncates title to first line when placeholders expand to multi-line content
- Falls back to branch name when template evaluates to blank
- Comprehensive specs for both feature flag states
Available placeholders for title templates
%{source_branch}, %{target_branch}, %{title_from_branch}, %{first_commit}, %{first_multiline_commit}
%{issue_title}is deferred to a later part where it can share issue resolution withBuildService#title_from_issueinstead of duplicating the logic.
Feature flag
- Name:
mr_default_title_template - Type:
beta
Related
- Depends on: database MR (Part 1) — merged
- Part of: #16080
Edited by Marc Shaw