Commit d6ed9920d68691472fe9f9a9247508573c64bae4
1 parent
3b41b183
Exists in
master
and in
4 other branches
#888 prevent to remove source_branch
Showing
4 changed files
with
9 additions
and
4 deletions
Show diff stats
app/models/merge_request.rb
@@ -189,7 +189,7 @@ class MergeRequest < ActiveRecord::Base | @@ -189,7 +189,7 @@ class MergeRequest < ActiveRecord::Base | ||
189 | self.merge!(current_user.id) | 189 | self.merge!(current_user.id) |
190 | true | 190 | true |
191 | end | 191 | end |
192 | - rescue | 192 | + rescue |
193 | self.mark_as_unmergable | 193 | self.mark_as_unmergable |
194 | false | 194 | false |
195 | end | 195 | end |
app/models/project/repository_trait.rb
@@ -114,5 +114,9 @@ module Project::RepositoryTrait | @@ -114,5 +114,9 @@ module Project::RepositoryTrait | ||
114 | def root_ref | 114 | def root_ref |
115 | default_branch || "master" | 115 | default_branch || "master" |
116 | end | 116 | end |
117 | + | ||
118 | + def root_ref? branch | ||
119 | + root_ref == branch | ||
120 | + end | ||
117 | end | 121 | end |
118 | end | 122 | end |
app/views/merge_requests/show.html.haml
@@ -65,8 +65,9 @@ | @@ -65,8 +65,9 @@ | ||
65 | = form_for [:automerge, @project, @merge_request], :remote => true, :method => :get do |f| | 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 | 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 | 67 | %br |
68 | - = check_box_tag :should_remove_source_branch | ||
69 | - = label_tag :should_remove_source_branch, "Remove source-branch" | 68 | + -unless @project.root_ref? @merge_request.source_branch |
69 | + = check_box_tag :should_remove_source_branch | ||
70 | + = label_tag :should_remove_source_branch, "Remove source-branch" | ||
70 | 71 | ||
71 | = f.submit "Accept Merge Request", :class => "btn small info accept_merge_request" | 72 | = f.submit "Accept Merge Request", :class => "btn small info accept_merge_request" |
72 | 73 |
lib/gitlab/merge.rb
@@ -50,7 +50,7 @@ module Gitlab | @@ -50,7 +50,7 @@ module Gitlab | ||
50 | output = merge_repo.git.pull({}, "--no-ff", "origin", merge_request.source_branch) | 50 | output = merge_repo.git.pull({}, "--no-ff", "origin", merge_request.source_branch) |
51 | 51 | ||
52 | #remove source-branch | 52 | #remove source-branch |
53 | - if merge_request.should_remove_source_branch | 53 | + if merge_request.should_remove_source_branch && !project.root_ref?(merge_request.source_branch) |
54 | merge_repo.git.sh "git push origin :#{merge_request.source_branch}" | 54 | merge_repo.git.sh "git push origin :#{merge_request.source_branch}" |
55 | end | 55 | end |
56 | 56 |