Commit d9bc57d1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'branches_with_no_parent' into 'master'

Branches with no parent cannot be merged

Solves `undefined method 'reduce' for false:FalseClass`

Fixes #1415

See merge request !967
parents bbef0ae0 7435b879
...@@ -95,6 +95,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -95,6 +95,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@note_counts = Note.where(commit_id: @commits.map(&:id)). @note_counts = Note.where(commit_id: @commits.map(&:id)).
group(:commit_id).count group(:commit_id).count
begin
@diffs = compare_action.diffs @diffs = compare_action.diffs
@merge_request.title = @merge_request.source_branch.titleize.humanize @merge_request.title = @merge_request.source_branch.titleize.humanize
@target_project = @merge_request.target_project @target_project = @merge_request.target_project
...@@ -103,6 +104,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -103,6 +104,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
diff_line_count = Commit::diff_line_count(@diffs) diff_line_count = Commit::diff_line_count(@diffs)
@suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count)
@force_suppress_diff = @suppress_diff @force_suppress_diff = @suppress_diff
rescue Gitlab::Satellite::BranchesWithoutParent
@error = "Selected branches have no common commit so they cannot be merged."
end
end end
end end
......
...@@ -10,8 +10,11 @@ ...@@ -10,8 +10,11 @@
%span.pull-right %span.pull-right
= link_to 'Change branches', new_project_merge_request_path(@project) = link_to 'Change branches', new_project_merge_request_path(@project)
- if @error.present?
= form_for [@project, @merge_request], html: { class: "merge-request-form" } do |f| .centered-light-block
%h4 #{@error}
- else
= form_for [@project, @merge_request], html: { class: "merge-request-form" } do |f|
.panel.panel-default .panel.panel-default
.panel-body .panel-body
...@@ -56,7 +59,7 @@ ...@@ -56,7 +59,7 @@
= f.hidden_field :source_branch = f.hidden_field :source_branch
= f.submit 'Submit merge request', class: "btn btn-create" = f.submit 'Submit merge request', class: "btn btn-create"
.mr-compare .mr-compare
%div.panel.panel-default %div.panel.panel-default
.panel-heading .panel-heading
Commits (#{@commits.count}) Commits (#{@commits.count})
......
module Gitlab module Gitlab
module Satellite module Satellite
class BranchesWithoutParent < StandardError; end
class CompareAction < Action class CompareAction < Action
def initialize(user, target_project, target_branch, source_project, source_branch) def initialize(user, target_project, target_branch, source_project, source_branch)
super user, target_project super user, target_project
...@@ -22,7 +24,7 @@ module Gitlab ...@@ -22,7 +24,7 @@ module Gitlab
diffs diffs
end end
rescue Grit::Git::CommandFailed => ex rescue Grit::Git::CommandFailed => ex
handle_exception(ex) raise BranchesWithoutParent
end end
# Retrieve an array of commits between the source and the target # Retrieve an array of commits between the source and the target
......
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