Commit 3b41b183 authored by Zevs's avatar Zevs

ability to remove source branch after merge

parent 11f72732
...@@ -109,6 +109,7 @@ class MergeRequestsController < ApplicationController ...@@ -109,6 +109,7 @@ class MergeRequestsController < ApplicationController
def automerge def automerge
return access_denied! unless can?(current_user, :accept_mr, @project) return access_denied! unless can?(current_user, :accept_mr, @project)
if @merge_request.open? && @merge_request.can_be_merged? if @merge_request.open? && @merge_request.can_be_merged?
@merge_request.should_remove_source_branch = params[:should_remove_source_branch]
@merge_request.automerge!(current_user) @merge_request.automerge!(current_user)
@status = true @status = true
else else
......
...@@ -14,7 +14,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -14,7 +14,8 @@ class MergeRequest < ActiveRecord::Base
serialize :st_diffs serialize :st_diffs
attr_protected :author, :author_id, :project, :project_id attr_protected :author, :author_id, :project, :project_id
attr_accessor :author_id_of_changes attr_accessor :author_id_of_changes,
:should_remove_source_branch
validates_presence_of :project_id validates_presence_of :project_id
validates_presence_of :assignee_id validates_presence_of :assignee_id
......
...@@ -62,9 +62,13 @@ ...@@ -62,9 +62,13 @@
.automerge_widget.can_be_merged{:style => "display:none"} .automerge_widget.can_be_merged{:style => "display:none"}
.alert.alert-success .alert.alert-success
%span %span
= link_to "Accept Merge Request", automerge_project_merge_request_path(@project, @merge_request), :class => "btn small info accept_merge_request", :remote => true = form_for [:automerge, @project, @merge_request], :remote => true, :method => :get do |f|
&nbsp; 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
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 %br
= check_box_tag :should_remove_source_branch
= label_tag :should_remove_source_branch, "Remove source-branch"
= f.submit "Accept Merge Request", :class => "btn small info accept_merge_request"
.automerge_widget.cannot_be_merged{:style => "display:none"} .automerge_widget.cannot_be_merged{:style => "display:none"}
.alert.alert-info .alert.alert-info
...@@ -108,7 +112,7 @@ ...@@ -108,7 +112,7 @@
current_state: "#{@merge_request.human_state}" current_state: "#{@merge_request.human_state}"
}); });
$(".accept_merge_request").live("ajax:beforeSend", function() { $(".edit_merge_request").live("ajax:beforeSend", function() {
$(this).replaceWith('#{image_tag "ajax_loader.gif"}'); $(this).replaceWith('#{image_tag "ajax_loader.gif"}');
}) })
}) })
......
...@@ -37,7 +37,7 @@ module Gitlab ...@@ -37,7 +37,7 @@ module Gitlab
unless project.satellite.exists? unless project.satellite.exists?
raise "You should run: rake gitlab:app:enable_automerge" raise "You should run: rake gitlab:app:enable_automerge"
end end
project.satellite.clear project.satellite.clear
Dir.chdir(project.satellite.path) do Dir.chdir(project.satellite.path) do
...@@ -48,6 +48,12 @@ module Gitlab ...@@ -48,6 +48,12 @@ module Gitlab
merge_repo.git.sh "git config user.email \"#{user.email}\"" merge_repo.git.sh "git config user.email \"#{user.email}\""
merge_repo.git.sh "git checkout -b #{merge_request.target_branch} origin/#{merge_request.target_branch}" merge_repo.git.sh "git checkout -b #{merge_request.target_branch} origin/#{merge_request.target_branch}"
output = merge_repo.git.pull({}, "--no-ff", "origin", merge_request.source_branch) output = merge_repo.git.pull({}, "--no-ff", "origin", merge_request.source_branch)
#remove source-branch
if merge_request.should_remove_source_branch
merge_repo.git.sh "git push origin :#{merge_request.source_branch}"
end
yield(merge_repo, output) yield(merge_repo, output)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment