Commit 6a800832 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Use same code for diff and patch inside MergeAction

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 7c6287c8
...@@ -49,14 +49,7 @@ module Gitlab ...@@ -49,14 +49,7 @@ module Gitlab
in_locked_and_timed_satellite do |merge_repo| in_locked_and_timed_satellite do |merge_repo|
prepare_satellite!(merge_repo) prepare_satellite!(merge_repo)
update_satellite_source_and_target!(merge_repo) update_satellite_source_and_target!(merge_repo)
if merge_request.for_fork?
diff = merge_repo.git.native(:diff, default_options, "origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}") diff = merge_repo.git.native(:diff, default_options, "origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}")
else
diff = merge_repo.git.native(:diff, default_options, "#{merge_request.target_branch}", "#{merge_request.source_branch}")
end
return diff
end end
rescue Grit::Git::CommandFailed => ex rescue Grit::Git::CommandFailed => ex
handle_exception(ex) handle_exception(ex)
...@@ -88,14 +81,7 @@ module Gitlab ...@@ -88,14 +81,7 @@ module Gitlab
in_locked_and_timed_satellite do |merge_repo| in_locked_and_timed_satellite do |merge_repo|
prepare_satellite!(merge_repo) prepare_satellite!(merge_repo)
update_satellite_source_and_target!(merge_repo) update_satellite_source_and_target!(merge_repo)
if (merge_request.for_fork?)
patch = merge_repo.git.format_patch(default_options({stdout: true}), "origin/#{merge_request.target_branch}..source/#{merge_request.source_branch}") patch = merge_repo.git.format_patch(default_options({stdout: true}), "origin/#{merge_request.target_branch}..source/#{merge_request.source_branch}")
else
patch = merge_repo.git.format_patch(default_options({stdout: true}), "#{merge_request.target_branch}..#{merge_request.source_branch}")
end
return patch
end end
rescue Grit::Git::CommandFailed => ex rescue Grit::Git::CommandFailed => ex
handle_exception(ex) handle_exception(ex)
......
...@@ -2,13 +2,12 @@ require 'spec_helper' ...@@ -2,13 +2,12 @@ require 'spec_helper'
describe 'Gitlab::Satellite::MergeAction' do describe 'Gitlab::Satellite::MergeAction' do
before(:each) do before(:each) do
# TestEnv.init(mailer: false, init_repos: true, repos: true)
@master = ['master', 'b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828'] @master = ['master', 'b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828']
@one_after_stable = ['stable', '6ea87c47f0f8a24ae031c3fff17bc913889ecd00'] #this commit sha is one after stable @one_after_stable = ['stable', '6ea87c47f0f8a24ae031c3fff17bc913889ecd00'] #this commit sha is one after stable
@wiki_branch = ['wiki', '635d3e09b72232b6e92a38de6cc184147e5bcb41'] #this is the commit sha where the wiki branch goes off from master @wiki_branch = ['wiki', '635d3e09b72232b6e92a38de6cc184147e5bcb41'] #this is the commit sha where the wiki branch goes off from master
@conflicting_metior = ['metior', '313d96e42b313a0af5ab50fa233bf43e27118b3f'] #this branch conflicts with the wiki branch @conflicting_metior = ['metior', '313d96e42b313a0af5ab50fa233bf43e27118b3f'] #this branch conflicts with the wiki branch
#these commits are quite close together, itended to make string diffs/format patches small # these commits are quite close together, itended to make string diffs/format patches small
@close_commit1 = ['2_3_notes_fix', '8470d70da67355c9c009e4401746b1d5410af2e3'] @close_commit1 = ['2_3_notes_fix', '8470d70da67355c9c009e4401746b1d5410af2e3']
@close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633'] @close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633']
end end
...@@ -16,6 +15,7 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -16,6 +15,7 @@ describe 'Gitlab::Satellite::MergeAction' do
let(:project) { create(:project_with_code) } let(:project) { create(:project_with_code) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:merge_request_fork) { create(:merge_request) } let(:merge_request_fork) { create(:merge_request) }
describe '#commits_between' do describe '#commits_between' do
def verify_commits(commits, first_commit_sha, last_commit_sha) def verify_commits(commits, first_commit_sha, last_commit_sha)
commits.each { |commit| commit.class.should == Gitlab::Git::Commit } commits.each { |commit| commit.class.should == Gitlab::Git::Commit }
......
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