summaryrefslogtreecommitdiff
path: root/app/services/compare_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/compare_service.rb')
-rw-r--r--app/services/compare_service.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 48ad7fab4e6..4c8b35edff8 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -1,3 +1,5 @@
+require 'securerandom'
+
# Compare 2 branches for one repo or between repositories
# and return Gitlab::CompareResult object that responds to commits and diffs
class CompareService
@@ -12,7 +14,22 @@ class CompareService
)
)
else
- raise 'Implement me'
+ random_string = SecureRandom.hex
+ target_project.repository.fetch_ref(
+ source_project.repository.path_to_repo,
+ "refs/heads/#{source_branch}",
+ "refs/tmp/#{random_string}/head"
+ )
+
+ source_sha = source_project.commit(source_branch).sha
+
+ Gitlab::CompareResult.new(
+ Gitlab::Git::Compare.new(
+ target_project.repository.raw_repository,
+ target_branch,
+ source_sha,
+ )
+ )
end
end
end