diff --git a/app/views/projects/merge_requests/widget/open/_accept.html.haml b/app/views/projects/merge_requests/widget/open/_accept.html.haml index 435fe835fae..66096ff7476 100644 --- a/app/views/projects/merge_requests/widget/open/_accept.html.haml +++ b/app/views/projects/merge_requests/widget/open/_accept.html.haml @@ -41,6 +41,7 @@ Modify commit message .js-toggle-content.hide.prepend-top-default = render 'shared/commit_message_container', params: params, + description: @merge_request.description, text: @merge_request.merge_commit_message, rows: 14, hint: true diff --git a/app/views/shared/_commit_message_container.html.haml b/app/views/shared/_commit_message_container.html.haml index 0a38327baa2..adee374413f 100644 --- a/app/views/shared/_commit_message_container.html.haml +++ b/app/views/shared/_commit_message_container.html.haml @@ -14,3 +14,31 @@ %p.hint Try to keep the first line under 52 characters and the others under 72. + - if local_assigns[:description] + %p.hint.use-description-hint + = link_to "#", class: "use-description-link" do + Use Merge Request description as merge commit message + %p.hint.use-default-message-hint.hide + = link_to "#", class: "use-default-message-link" do + Use default Gitlab merge commit message + + + :javascript + $('.use-description-link').on('click', function(e) { + e.preventDefault(); + + $('.use-description-hint').hide(); + $('.use-default-message-hint').show(); + $('.js-commit-message').val("#{escape_javascript local_assigns[:description]}"); + }); + + $('.use-default-message-link').on('click', function(e) { + e.preventDefault(); + + var defaultMessage = "#{escape_javascript (params[:commit_message] || local_assigns[:text] || local_assigns[:placeholder])}"; + + $('.use-description-hint').show(); + $('.use-default-message-hint').hide(); + $('.js-commit-message').val(defaultMessage); + }); +