From 58064027408bcbfb9e6216a3157dffd9c324848d Mon Sep 17 00:00:00 2001 From: Izaak Alpert <ialpert@blackberry.com> Date: Wed, 17 Jul 2013 16:28:07 -0400 Subject: [PATCH] Raise Error for diff_between/commit_between for non fork mr's in satellite -Fixed tests to account for this -Trigger update after update_branches for list:update selecting first commit, have it also trigger sha lookup Change-Id: Ie4c3d4fbf57aeadd7d141d3704f4ea0f0684a7a5 --- .../merge_requests/update_branches.js.haml | 3 ++- lib/gitlab/satellite/merge_action.rb | 6 ++---- spec/lib/gitlab/satellite/merge_action_spec.rb | 16 ++++------------ 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/app/views/projects/merge_requests/update_branches.js.haml b/app/views/projects/merge_requests/update_branches.js.haml index 7324aa89a5..db25ae3b91 100644 --- a/app/views/projects/merge_requests/update_branches.js.haml +++ b/app/views/projects/merge_requests/update_branches.js.haml @@ -1,4 +1,5 @@ :plain $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}"); $(".target_branch").trigger("liszt:updated"); - $(".mr_target_commit").html(""); \ No newline at end of file + $(".mr_target_commit").html(""); + $(".target_branch").trigger("change"); \ No newline at end of file diff --git a/lib/gitlab/satellite/merge_action.rb b/lib/gitlab/satellite/merge_action.rb index 3610a18bc9..6f402e80a6 100644 --- a/lib/gitlab/satellite/merge_action.rb +++ b/lib/gitlab/satellite/merge_action.rb @@ -74,9 +74,7 @@ module Gitlab #this method doesn't take default options diffs = merge_repo.diff(common_commit, "source/#{merge_request.source_branch}") else - common_commit = merge_repo.git.native(:merge_base, default_options, ["#{merge_request.target_branch}", "#{merge_request.source_branch}"]).strip - #this method doesn't take default options - diffs = merge_repo.diff(common_commit, "#{merge_request.source_branch}") + raise "Attempt to determine diffs between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]" end diffs = diffs.map { |diff| Gitlab::Git::Diff.new(diff) } return diffs @@ -109,7 +107,7 @@ module Gitlab if (merge_request.for_fork?) commits = merge_repo.commits_between("origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}") else - commits = merge_repo.commits_between("#{merge_request.target_branch}", "#{merge_request.source_branch}") + raise "Attempt to determine commits between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]" end commits = commits.map { |commit| Gitlab::Git::Commit.new(commit, nil) } return commits diff --git a/spec/lib/gitlab/satellite/merge_action_spec.rb b/spec/lib/gitlab/satellite/merge_action_spec.rb index 2478efe849..98e475e715 100644 --- a/spec/lib/gitlab/satellite/merge_action_spec.rb +++ b/spec/lib/gitlab/satellite/merge_action_spec.rb @@ -38,16 +38,14 @@ describe 'Gitlab::Satellite::MergeAction' do end context 'between branches' do - it 'should get proper commits between' do + it 'should raise exception -- not expected to be used by non forks' do merge_request.target_branch = @one_after_stable[0] merge_request.source_branch = @master[0] - commits = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between - verify_commits(commits, @one_after_stable[1], @master[1]) + expect {Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between}.to raise_error merge_request.target_branch = @wiki_branch[0] merge_request.source_branch = @master[0] - commits = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between - verify_commits(commits, @wiki_branch[1], @master[1]) + expect {Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between}.to raise_error end end end @@ -104,13 +102,7 @@ describe 'Gitlab::Satellite::MergeAction' do it 'should get proper diffs' do merge_request.target_branch = @close_commit1[0] merge_request.source_branch = @master[0] - diffs = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite - - merge_request.target_branch = @close_commit1[0] - merge_request.source_branch = @master[0] - diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diff_in_satellite - - is_a_matching_diff(diff, diffs) + expect{Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite}.to raise_error end end end -- 2.30.9