diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2017-12-06 16:54:57 +0100 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2017-12-13 17:40:19 +0100 |
commit | 835a5db376a69dce20ba616d480a5a9ab15b2577 (patch) | |
tree | 0ecba5bbfa679966cba50e62b0ff19c4d944fc12 /lib | |
parent | 689bc9ea6db102006b548e6176125157955c7f2b (diff) | |
download | gitlab-ce-835a5db376a69dce20ba616d480a5a9ab15b2577.tar.gz |
Migrate Gitlab::Git::Repository#merge_base_commit to Gitalyfeature/migrate-merge-base-to-gitaly
Closes gitaly#808
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/operation_service.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/repository_service.rb | 10 |
3 files changed, 19 insertions, 2 deletions
diff --git a/lib/gitlab/git/operation_service.rb b/lib/gitlab/git/operation_service.rb index 7e8fe173056..ef5bdbaf819 100644 --- a/lib/gitlab/git/operation_service.rb +++ b/lib/gitlab/git/operation_service.rb @@ -126,7 +126,7 @@ module Gitlab oldrev = branch.target - if oldrev == repository.rugged.merge_base(newrev, branch.target) + if oldrev == repository.merge_base(newrev, branch.target) oldrev else raise Gitlab::Git::CommitError.new('Branch diverged') diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 73889328f36..816fbbeaef8 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -516,8 +516,15 @@ module Gitlab # Returns the SHA of the most recent common ancestor of +from+ and +to+ def merge_base_commit(from, to) - rugged.merge_base(from, to) + gitaly_migrate(:merge_base) do |is_enabled| + if is_enabled + gitaly_repository_client.find_merge_base(from, to) + else + rugged.merge_base(from, to) + end + end end + alias_method :merge_base, :merge_base_commit # Gitaly note: JV: check gitlab-ee before removing this method. def rugged_is_ancestor?(ancestor_id, descendant_id) diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index a477d618f63..c1f95396878 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -69,6 +69,16 @@ module Gitlab response.value end + def find_merge_base(*revisions) + request = Gitaly::FindMergeBaseRequest.new( + repository: @gitaly_repo, + revisions: revisions.map { |r| GitalyClient.encode(r) } + ) + + response = GitalyClient.call(@storage, :repository_service, :find_merge_base, request) + response.base.presence + end + def fetch_source_branch(source_repository, source_branch, local_ref) request = Gitaly::FetchSourceBranchRequest.new( repository: @gitaly_repo, |