Commit 098ee55e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Use CompareService in collecting diff when create MR

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent bf9ce1f4
...@@ -83,11 +83,7 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -83,11 +83,7 @@ class MergeRequestDiff < ActiveRecord::Base
# Collect array of Git::Commit objects # Collect array of Git::Commit objects
# between target and source branches # between target and source branches
def unmerged_commits def unmerged_commits
commits = if merge_request.for_fork? commits = compare_result.commits
compare_action.commits
else
repository.commits_between(target_branch, source_branch)
end
if commits.present? if commits.present?
commits = Commit.decorate(commits). commits = Commit.decorate(commits).
...@@ -147,12 +143,7 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -147,12 +143,7 @@ class MergeRequestDiff < ActiveRecord::Base
# Collect array of Git::Diff objects # Collect array of Git::Diff objects
# between target and source branches # between target and source branches
def unmerged_diffs def unmerged_diffs
diffs = if merge_request.for_fork? diffs = compare_result.diffs
compare_action.diffs
else
Gitlab::Git::Diff.between(repository, source_branch, target_branch)
end
diffs ||= [] diffs ||= []
diffs diffs
rescue Gitlab::Git::Diff::TimeoutError => ex rescue Gitlab::Git::Diff::TimeoutError => ex
...@@ -166,13 +157,13 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -166,13 +157,13 @@ class MergeRequestDiff < ActiveRecord::Base
private private
def compare_action def compare_result
Gitlab::Satellite::CompareAction.new( @compare_result ||= CompareService.new.execute(
merge_request.author, merge_request.author,
merge_request.source_project,
merge_request.source_branch,
merge_request.target_project, merge_request.target_project,
merge_request.target_branch, merge_request.target_branch,
merge_request.source_project,
merge_request.source_branch
) )
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