Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-08 14:11:52 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-12-08 14:11:52 +0300
commit07b9b80a8833cf44ba804c9b8dfdf1550785fe83 (patch)
tree4bb39bfd0ca4c7255dc150b015c272be2e26aa72 /app/services/compare_service.rb
parent8384d0d8d528ffdd60c9ba9e3c0c9f688cb560ef (diff)
Fix tests to use the new API
Diffstat (limited to 'app/services/compare_service.rb')
-rw-r--r--app/services/compare_service.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 4367cb5f615..199a015622e 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -3,29 +3,31 @@ require 'securerandom'
# Compare 2 branches for one repo or between repositories
# and return Gitlab::Git::Compare object that responds to commits and diffs
class CompareService
- attr_reader :source_project, :source_sha
+ attr_reader :source_project, :source_branch
- def initialize(new_source_project, source_branch)
+ def initialize(new_source_project, source_branch_name)
@source_project = new_source_project
- @source_sha = new_source_project.commit(source_branch).try(:sha)
+ @source_branch = new_source_project.commit(source_branch_name)
end
def execute(target_project, target_branch, straight: false)
+ source_sha = source_branch.try(:sha)
+
return unless source_sha
# If compare with other project we need to fetch ref first
if target_project == source_project
- compare(target_project, target_branch, straight)
+ compare(source_sha, target_project, target_branch, straight)
else
target_project.repository.with_tmp_ref(source_project, source_branch) do
- compare(target_project, target_branch, straight)
+ compare(source_sha, target_project, target_branch, straight)
end
end
end
private
- def compare(target_project, target_branch, straight)
+ def compare(source_sha, target_project, target_branch, straight)
raw_compare = Gitlab::Git::Compare.new(
target_project.repository.raw_repository,
target_branch,