Commit 58064027 authored by Izaak Alpert's avatar Izaak Alpert

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
parent 0e82c981
:plain :plain
$(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}"); $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}");
$(".target_branch").trigger("liszt:updated"); $(".target_branch").trigger("liszt:updated");
$(".mr_target_commit").html(""); $(".mr_target_commit").html("");
\ No newline at end of file $(".target_branch").trigger("change");
\ No newline at end of file
...@@ -74,9 +74,7 @@ module Gitlab ...@@ -74,9 +74,7 @@ module Gitlab
#this method doesn't take default options #this method doesn't take default options
diffs = merge_repo.diff(common_commit, "source/#{merge_request.source_branch}") diffs = merge_repo.diff(common_commit, "source/#{merge_request.source_branch}")
else else
common_commit = merge_repo.git.native(:merge_base, default_options, ["#{merge_request.target_branch}", "#{merge_request.source_branch}"]).strip raise "Attempt to determine diffs between for a non forked merge request in satellite MergeRequest.id:[#{merge_request.id}]"
#this method doesn't take default options
diffs = merge_repo.diff(common_commit, "#{merge_request.source_branch}")
end end
diffs = diffs.map { |diff| Gitlab::Git::Diff.new(diff) } diffs = diffs.map { |diff| Gitlab::Git::Diff.new(diff) }
return diffs return diffs
...@@ -109,7 +107,7 @@ module Gitlab ...@@ -109,7 +107,7 @@ module Gitlab
if (merge_request.for_fork?) if (merge_request.for_fork?)
commits = merge_repo.commits_between("origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}") commits = merge_repo.commits_between("origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}")
else 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 end
commits = commits.map { |commit| Gitlab::Git::Commit.new(commit, nil) } commits = commits.map { |commit| Gitlab::Git::Commit.new(commit, nil) }
return commits return commits
......
...@@ -38,16 +38,14 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -38,16 +38,14 @@ describe 'Gitlab::Satellite::MergeAction' do
end end
context 'between branches' do 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.target_branch = @one_after_stable[0]
merge_request.source_branch = @master[0] merge_request.source_branch = @master[0]
commits = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between expect {Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between}.to raise_error
verify_commits(commits, @one_after_stable[1], @master[1])
merge_request.target_branch = @wiki_branch[0] merge_request.target_branch = @wiki_branch[0]
merge_request.source_branch = @master[0] merge_request.source_branch = @master[0]
commits = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between expect {Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between}.to raise_error
verify_commits(commits, @wiki_branch[1], @master[1])
end end
end end
end end
...@@ -104,13 +102,7 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -104,13 +102,7 @@ describe 'Gitlab::Satellite::MergeAction' do
it 'should get proper diffs' do it 'should get proper diffs' do
merge_request.target_branch = @close_commit1[0] merge_request.target_branch = @close_commit1[0]
merge_request.source_branch = @master[0] merge_request.source_branch = @master[0]
diffs = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite expect{Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite}.to raise_error
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)
end end
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