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:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-11 15:33:31 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-11 15:33:31 +0300
commit3e259ea8bc198b7a5c67bd1e03dc9d44c7dd5854 (patch)
treef726369d15ae21d54272c586a30db4102817af6e /app/services/compare_service.rb
parentc0bf026ed8253e9bf749546e40f968dbc20aaac1 (diff)
Revert "Merge branch 'revert-satellites' into 'master' "
This reverts commit 5daf44b7c86e0e2641a902b1da8b01d91fa3dbfa, reversing changes made to 2f706fbd231cabe7a76a5d17ac44285aaaf8592c.
Diffstat (limited to 'app/services/compare_service.rb')
-rw-r--r--app/services/compare_service.rb41
1 files changed, 21 insertions, 20 deletions
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 6aa9df4b194..70f642baaaa 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -1,27 +1,28 @@
+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(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,
- )
+ 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"
)
- else
- Gitlab::Satellite::CompareAction.new(
- current_user,
- target_project,
- target_branch,
- source_project,
- source_branch
- ).result
end
+
+ Gitlab::CompareResult.new(
+ Gitlab::Git::Compare.new(
+ target_project.repository.raw_repository,
+ target_branch,
+ source_sha,
+ )
+ )
end
end