summaryrefslogtreecommitdiff
path: root/app/services/compare_service.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-11 10:28:42 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-11 10:28:42 +0200
commit9f10943c1a76576ac40d96189a28a4d6123a75d8 (patch)
tree88955d92ebc98a4165d66a36cb8a2cf92709981a /app/services/compare_service.rb
parent84727fba96c6794874e1f94d581408b70e1842a7 (diff)
downloadgitlab-ce-9f10943c1a76576ac40d96189a28a4d6123a75d8.tar.gz
Revert "Merge branch 'drop-satellites'"
This reverts commit 957e849f41d96fa9778fcdd06792d2f0274b29ab, reversing changes made to 6b9dbe9f5a175a8162abf296367f561bab3eea1a. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/services/compare_service.rb')
-rw-r--r--app/services/compare_service.rb41
1 files changed, 20 insertions, 21 deletions
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 70f642baaaa..6aa9df4b194 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -1,28 +1,27 @@
-require 'securerandom'
-
# Compare 2 branches for one repo or between repositories
# and return Gitlab::CompareResult object that responds to commits and diffs
class CompareService
- def execute(source_project, source_branch, target_project, target_branch)
- source_sha = source_project.commit(source_branch).sha
-
- # If compare with other project we need to fetch ref first
- unless target_project == source_project
- random_string = SecureRandom.hex
-
- target_project.repository.fetch_ref(
- source_project.repository.path_to_repo,
- "refs/heads/#{source_branch}",
- "refs/tmp/#{random_string}/head"
+ def execute(current_user, source_project, source_branch, target_project, target_branch)
+ # Try to compare branches to get commits list and diffs
+ #
+ # Note: Use satellite only when need to compare between two repos
+ # because satellites are slower than operations on bare repo
+ if target_project == source_project
+ Gitlab::CompareResult.new(
+ Gitlab::Git::Compare.new(
+ target_project.repository.raw_repository,
+ target_branch,
+ source_branch,
+ )
)
- end
-
- Gitlab::CompareResult.new(
- Gitlab::Git::Compare.new(
- target_project.repository.raw_repository,
+ else
+ Gitlab::Satellite::CompareAction.new(
+ current_user,
+ target_project,
target_branch,
- source_sha,
- )
- )
+ source_project,
+ source_branch
+ ).result
+ end
end
end