Commit 73692f21 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #888 from gitlabhq/remove_sorce_branch_after_merge

ability to remove source branch after merge
parents 11f72732 2d68e7f4
...@@ -714,6 +714,19 @@ p.time { ...@@ -714,6 +714,19 @@ p.time {
text-align:center; text-align:center;
float:left; float:left;
margin-right:20px; margin-right:20px;
&.success {
background: #5BB75B;
color: white;
text-shadow: 0 1px #111;
border-color: #9A9;
}
&.error {
background: #DA4E49;
border-color: #BD362F;
color: white;
text-shadow: 0 1px #111;
}
} }
.arrow{ .arrow{
...@@ -864,15 +877,36 @@ li.note { ...@@ -864,15 +877,36 @@ li.note {
background: #DFF0D8; background: #DFF0D8;
} }
form {
margin-bottom:0;
.clearfix {
margin-bottom:0;
}
}
.accept_group {
float:left;
border: 1px solid #ADA;
padding: 2px;
@include border-radius(5px);
border-radius: 5px;
background: #CEB;
.accept_merge_request { .accept_merge_request {
color: #fff; float:left;
text-shadow: 0 1px 1px #222; }
background: #5bb75b;; .remove_branch_holder {
&:hover { margin-left:20px;
background-color: #51a351; margin-right:10px;
color: #fff; float:left;
}
label {
color:#444;
} }
} }
.how_to_merge_link { .how_to_merge_link {
@extend .primary; @extend .primary;
} }
......
...@@ -127,6 +127,18 @@ table { ...@@ -127,6 +127,18 @@ table {
@extend .btn-primary; @extend .btn-primary;
} }
&.success {
color: #fff;
text-shadow: 0 0 1px #111;
background: #5bb75b;;
font-weight: bold;
&:hover {
background-color: #51a351;
color: #fff;
}
}
&.danger, &.danger,
&.btn-danger { &.btn-danger {
color:#fff; color:#fff;
......
...@@ -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
......
...@@ -114,5 +114,9 @@ module Project::RepositoryTrait ...@@ -114,5 +114,9 @@ module Project::RepositoryTrait
def root_ref def root_ref
default_branch || "master" default_branch || "master"
end end
def root_ref? branch
root_ref == branch
end
end end
end end
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
%span.right %span.right
- if can?(current_user, :modify_merge_request, @merge_request) - if can?(current_user, :modify_merge_request, @merge_request)
- if @merge_request.open? - if @merge_request.open?
= link_to 'Close', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => true }, :status_only => true), :method => :put, :class => "btn small padded", :title => "Close merge request" = link_to 'Close', project_merge_request_path(@project, @merge_request, :merge_request => {:closed => true }, :status_only => true), :method => :put, :class => "btn small padded danger", :title => "Close merge request"
= link_to edit_project_merge_request_path(@project, @merge_request), :class => "btn small padded" do = link_to edit_project_merge_request_path(@project, @merge_request), :class => "btn small padded" do
%i.icon-edit %i.icon-edit
Edit Edit
...@@ -62,9 +62,21 @@ ...@@ -62,9 +62,21 @@
.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; %p
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 -
%strong= link_to "click here", "#", :class => "how_to_merge_link vlink", :title => "How To Merge"
for instructions
.accept_group
= f.submit "Accept Merge Request", :class => "btn small success accept_merge_request"
- unless @project.root_ref? @merge_request.source_branch
.remove_branch_holder
= label_tag :should_remove_source_branch, :class => "checkbox" do
= check_box_tag :should_remove_source_branch
Remove source-branch
.clearfix
.automerge_widget.cannot_be_merged{:style => "display:none"} .automerge_widget.cannot_be_merged{:style => "display:none"}
.alert.alert-info .alert.alert-info
...@@ -108,7 +120,7 @@ ...@@ -108,7 +120,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"}');
}) })
}) })
......
...@@ -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 && !project.root_ref?(merge_request.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