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>2017-01-04 20:52:21 +0300
committerLin Jen-Shin <godfat@godfat.org>2017-01-04 20:52:21 +0300
commit99ac0935271b1e99f4512e496104219045f1018e (patch)
treee79085e860ecd2adf281519e3e0bd5c9441a6ae6 /app/services/compare_service.rb
parent05d742a047cca3ded10e6e3a545e211a3592c89c (diff)
Introduce Repository#with_repo_branch_commit
We merge repository checks inside it so we don't have to check it on the call site, and we could also load the commit for the caller. This greatly reduce code duplication. Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7237#note_20572919
Diffstat (limited to 'app/services/compare_service.rb')
-rw-r--r--app/services/compare_service.rb18
1 files changed, 6 insertions, 12 deletions
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 31c371c4b34..d3d613661a6 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -11,19 +11,13 @@ class CompareService
end
def execute(target_project, target_branch, straight: false)
- source_sha = source_project.repository.
- commit(source_branch_name).try(:sha)
-
- return unless source_sha
-
# If compare with other project we need to fetch ref first
- if target_project == source_project
- compare(source_sha, target_project, target_branch, straight)
- else
- target_project.repository.with_tmp_ref(
- source_project.repository, source_branch_name) do
- compare(source_sha, target_project, target_branch, straight)
- end
+ target_project.repository.with_repo_branch_commit(
+ source_project.repository,
+ source_branch_name) do |commit|
+ break unless commit
+
+ compare(commit.sha, target_project, target_branch, straight)
end
end