Show default value in squash and merge commit template textareas

Merged Piotr Stankowski requested to merge trakos/gitlab:merge_commit_template_default_value into master

What does this MR do and why?

Solves #348707 (closed)

Shows default value in a textareas for squash and merge commit templates instead of placeholders.

At the same time, it persists nil to database instead when default value is used.

This fixes rendering problem for placeholder with new lines (it does not render in Safari, possibly others).

Screenshots or screen recordings

For projects without any value set:



Plus on safari the placeholder doesn't render correctly:


After - default values are prefilled in textareas:


After - when user clears the values:


Note that for merge suggestions I've only added the help text. It's a one line text field, so there's no issue with placeholder there.

How to set up and validate locally

  1. Go to any project -> settings -> general.
  2. Expand Merge Requests section.
  3. Check that "Merge commit message template" and "Squash commit message template" is prefilled with default values.
  4. Change the value and confirm that it updated in DB.
  5. Change back to default value and confirm that it is nil in DB, but shows as default value in textarea.
  6. Change to empty value and confirm that it is nil in DB, but shows as default value in textarea.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Michael Kozono