Commit 3b41b1839b36b1063674af6acc659e43a97c8c39
1 parent
11f72732
Exists in
master
and in
4 other branches
ability to remove source branch after merge
Showing
4 changed files
with
18 additions
and
6 deletions
Show diff stats
app/controllers/merge_requests_controller.rb
| ... | ... | @@ -109,6 +109,7 @@ class MergeRequestsController < ApplicationController |
| 109 | 109 | def automerge |
| 110 | 110 | return access_denied! unless can?(current_user, :accept_mr, @project) |
| 111 | 111 | if @merge_request.open? && @merge_request.can_be_merged? |
| 112 | + @merge_request.should_remove_source_branch = params[:should_remove_source_branch] | |
| 112 | 113 | @merge_request.automerge!(current_user) |
| 113 | 114 | @status = true |
| 114 | 115 | else | ... | ... |
app/models/merge_request.rb
| ... | ... | @@ -14,7 +14,8 @@ class MergeRequest < ActiveRecord::Base |
| 14 | 14 | serialize :st_diffs |
| 15 | 15 | |
| 16 | 16 | attr_protected :author, :author_id, :project, :project_id |
| 17 | - attr_accessor :author_id_of_changes | |
| 17 | + attr_accessor :author_id_of_changes, | |
| 18 | + :should_remove_source_branch | |
| 18 | 19 | |
| 19 | 20 | validates_presence_of :project_id |
| 20 | 21 | validates_presence_of :assignee_id | ... | ... |
app/views/merge_requests/show.html.haml
| ... | ... | @@ -62,9 +62,13 @@ |
| 62 | 62 | .automerge_widget.can_be_merged{:style => "display:none"} |
| 63 | 63 | .alert.alert-success |
| 64 | 64 | %span |
| 65 | - = link_to "Accept Merge Request", automerge_project_merge_request_path(@project, @merge_request), :class => "btn small info accept_merge_request", :remote => true | |
| 66 | - | |
| 67 | - You can accept this request automatically. If you still want to do it manually - #{link_to "click here", "#", :class => "how_to_merge_link vlink", :title => "How To Merge"} for instructions | |
| 65 | + = form_for [:automerge, @project, @merge_request], :remote => true, :method => :get do |f| | |
| 66 | + You can accept this request automatically. If you still want to do it manually - #{link_to "click here", "#", :class => "how_to_merge_link vlink", :title => "How To Merge"} for instructions | |
| 67 | + %br | |
| 68 | + = check_box_tag :should_remove_source_branch | |
| 69 | + = label_tag :should_remove_source_branch, "Remove source-branch" | |
| 70 | + | |
| 71 | + = f.submit "Accept Merge Request", :class => "btn small info accept_merge_request" | |
| 68 | 72 | |
| 69 | 73 | .automerge_widget.cannot_be_merged{:style => "display:none"} |
| 70 | 74 | .alert.alert-info |
| ... | ... | @@ -108,7 +112,7 @@ |
| 108 | 112 | current_state: "#{@merge_request.human_state}" |
| 109 | 113 | }); |
| 110 | 114 | |
| 111 | - $(".accept_merge_request").live("ajax:beforeSend", function() { | |
| 115 | + $(".edit_merge_request").live("ajax:beforeSend", function() { | |
| 112 | 116 | $(this).replaceWith('#{image_tag "ajax_loader.gif"}'); |
| 113 | 117 | }) |
| 114 | 118 | }) | ... | ... |
lib/gitlab/merge.rb
| ... | ... | @@ -37,7 +37,7 @@ module Gitlab |
| 37 | 37 | unless project.satellite.exists? |
| 38 | 38 | raise "You should run: rake gitlab:app:enable_automerge" |
| 39 | 39 | end |
| 40 | - | |
| 40 | + | |
| 41 | 41 | project.satellite.clear |
| 42 | 42 | |
| 43 | 43 | Dir.chdir(project.satellite.path) do |
| ... | ... | @@ -48,6 +48,12 @@ module Gitlab |
| 48 | 48 | merge_repo.git.sh "git config user.email \"#{user.email}\"" |
| 49 | 49 | merge_repo.git.sh "git checkout -b #{merge_request.target_branch} origin/#{merge_request.target_branch}" |
| 50 | 50 | output = merge_repo.git.pull({}, "--no-ff", "origin", merge_request.source_branch) |
| 51 | + | |
| 52 | + #remove source-branch | |
| 53 | + if merge_request.should_remove_source_branch | |
| 54 | + merge_repo.git.sh "git push origin :#{merge_request.source_branch}" | |
| 55 | + end | |
| 56 | + | |
| 51 | 57 | yield(merge_repo, output) |
| 52 | 58 | end |
| 53 | 59 | end | ... | ... |