diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-15 17:45:38 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-15 17:45:50 +0300 |
commit | 2a6f522cac52ead493aa9f69017e2d7780c342a1 (patch) | |
tree | c8e07719922a5e171d10dff9099f0c7c72d0a8d8 /app/services | |
parent | 2be3c949258e45850d55c36b67fc4d5306a626ff (diff) |
Implement merge from forks without satellites
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/compare_service.rb | 19 | ||||
-rw-r--r-- | app/services/merge_requests/auto_merge_service.rb | 10 |
2 files changed, 21 insertions, 8 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 diff --git a/app/services/merge_requests/auto_merge_service.rb b/app/services/merge_requests/auto_merge_service.rb index 1c41148d41d..3db498acfcd 100644 --- a/app/services/merge_requests/auto_merge_service.rb +++ b/app/services/merge_requests/auto_merge_service.rb @@ -31,12 +31,8 @@ module MergeRequests end def merge! - if merge_request.for_fork? - raise 'Implement me' - else - if sha = commit - after_commit(sha, merge_request.target_branch) - end + if sha = commit + after_commit(sha, merge_request.target_branch) end end @@ -49,7 +45,7 @@ module MergeRequests committer: committer } - repository.merge(merge_request.source_branch, merge_request.target_branch, options) + repository.merge(merge_request.source_sha, merge_request.target_branch, options) end def after_commit(sha, branch) |