diff options
author | John Cai <jcai@gitlab.com> | 2019-01-02 16:33:34 -0800 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2019-01-02 16:55:44 -0800 |
commit | 4cee835a10497da6fdd3364cfc4fc03c0f1c455b (patch) | |
tree | 2dcb3ea486751674ada9a2dcacc9fd6fb08d55c7 | |
parent | 6f832226f0ab70859642b87458cb00012b283101 (diff) | |
download | gitlab-ce-support-left-right-gitaly.tar.gz |
directly use --left-rightsupport-left-right-gitaly
-rw-r--r-- | lib/gitlab/git/repository.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/commit_service.rb | 18 |
2 files changed, 19 insertions, 7 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 5bbedc9d5e3..25917ed95ce 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -359,13 +359,7 @@ module Gitlab if options[:left_right] from = options[:from] to = options[:to] - - right_count = gitaly_commit_client - .commit_count("#{from}..#{to}", options) - left_count = gitaly_commit_client - .commit_count("#{to}..#{from}", options) - - [left_count, right_count] + gitaly_commit_client.divergent_commit_count("#{from}...#{to}", options) else gitaly_commit_client.commit_count(options[:ref], options) end diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 4e46cb9f05c..1df46853315 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -146,10 +146,28 @@ module Gitlab request.before = Google::Protobuf::Timestamp.new(seconds: options[:before].to_i) if options[:before].present? request.path = encode_binary(options[:path]) if options[:path].present? request.max_count = options[:max_count] if options[:max_count].present? + request.left_right = options[:left_right] if options[:left_right].present? GitalyClient.call(@repository.storage, :commit_service, :count_commits, request, timeout: GitalyClient.medium_timeout).count end + def divergent_commit_count(ref, options = {}) + request = Gitaly::CountCommitsRequest.new( + repository: @gitaly_repo, + revision: encode_binary(ref), + all: !!options[:all] + ) + request.after = Google::Protobuf::Timestamp.new(seconds: options[:after].to_i) if options[:after].present? + request.before = Google::Protobuf::Timestamp.new(seconds: options[:before].to_i) if options[:before].present? + request.path = encode_binary(options[:path]) if options[:path].present? + request.max_count = options[:max_count] if options[:max_count].present? + request.left_right = options[:left_right] if options[:left_right].present? + + response = GitalyClient.call(@repository.storage, :commit_service, :count_commits, request, timeout: GitalyClient.medium_timeout) + + [response.left_count, response.right_count] + end + def list_last_commits_for_tree(revision, path, offset: 0, limit: 25) request = Gitaly::ListLastCommitsForTreeRequest.new( repository: @gitaly_repo, |