Skip to content
Snippets Groups Projects
Commit 207bc8a0 authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Branches without parent commit cannot be merged.

parent 25c9bf4b
No related branches found
No related tags found
No related merge requests found
Loading
@@ -95,6 +95,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -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
Loading
@@ -103,6 +104,9 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -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 compared."
end
end end
end end
   
Loading
Loading
Loading
@@ -10,7 +10,10 @@
Loading
@@ -10,7 +10,10 @@
   
%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?
.centered-light-block
%h4 #{@error}
- else
= form_for [@project, @merge_request], html: { class: "merge-request-form" } do |f| = form_for [@project, @merge_request], html: { class: "merge-request-form" } do |f|
.panel.panel-default .panel.panel-default
   
Loading
Loading
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
Loading
@@ -22,7 +24,7 @@ module Gitlab
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment