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_template feature flag (project actor)
  • Adds new_mr_title method to MessageGenerator with allowlisted placeholders
  • Adds title_from_branch placeholder variable
  • Extracts mr_title_template_enabled? predicate for readability
  • Moves humanize_branch_name to MessageGenerator as a shared class method
  • Memoizes MessageGenerator via strong_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 with BuildService#title_from_issue instead of duplicating the logic.

Feature flag

  • Name: mr_default_title_template
  • Type: beta
  • Depends on: database MR (Part 1) — merged
  • Part of: #16080
Edited by Marc Shaw

Merge request reports

Loading