%div#modal_merge_info.modal
  .modal-dialog
    .modal-content
      .modal-header
        %a.close{href: "#", "data-dismiss" => "modal"} ×
        %h3 Check out, review, and merge locally
      .modal-body
        %p
          %strong Step 1.
          Fetch and check out the branch for this merge request
        = clipboard_button(clipboard_target: "pre#merge-info-1")
        %pre.dark#merge-info-1
          - if @merge_request.for_fork?
            :preserve
              git fetch #{h default_url_to_repo(@merge_request.source_project)} #{h @merge_request.source_branch}
              git checkout -b #{h @merge_request.source_project_path}-#{h @merge_request.source_branch} FETCH_HEAD
          - else
            :preserve
              git fetch origin
              git checkout -b #{h @merge_request.source_branch} origin/#{h @merge_request.source_branch}
        %p
          %strong Step 2.
          Review the changes locally

        %p
          %strong Step 3.
          Merge the branch and fix any conflicts that come up
        = clipboard_button(clipboard_target: "pre#merge-info-3")
        %pre.dark#merge-info-3
          - if @merge_request.for_fork?
            :preserve
              git checkout #{h @merge_request.target_branch}
              git merge --no-ff #{h @merge_request.source_project_path}-#{h @merge_request.source_branch}
          - else
            :preserve
              git checkout #{h @merge_request.target_branch}
              git merge --no-ff #{h @merge_request.source_branch}
        %p
          %strong Step 4.
          Push the result of the merge to GitLab
        = clipboard_button(clipboard_target: "pre#merge-info-4")
        %pre.dark#merge-info-4
          :preserve
            git push origin #{h @merge_request.target_branch}
        - unless @merge_request.can_be_merged_by?(current_user)
          %p
            Note that pushing to GitLab requires write access to this repository.
        %p
          %strong Tip:
          = succeed '.' do
            You can also checkout merge requests locally by
            = link_to 'following these guidelines', help_page_path('user/project/merge_requests.md', anchor: "checkout-merge-requests-locally"), target: '_blank'

:javascript
  $(function(){
    var modal = $('#modal_merge_info').modal({modal: true, show:false});
    $('.how_to_merge_link').bind("click", function(){
      modal.show();
    });
    $('.modal-header .close').bind("click", function(){
      modal.hide();
    })
  })