Add support for max_count option to Git::Repository#count_commits
This commit is contained in:
parent
af490ea87b
commit
13932b0b12
|
@ -1 +1 @@
|
|||
0.64.0
|
||||
0.65.0
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -402,7 +402,7 @@ group :ed25519 do
|
|||
end
|
||||
|
||||
# Gitaly GRPC client
|
||||
gem 'gitaly-proto', '~> 0.62.0', require: 'gitaly'
|
||||
gem 'gitaly-proto', '~> 0.64.0', require: 'gitaly'
|
||||
|
||||
gem 'toml-rb', '~> 0.3.15', require: false
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ GEM
|
|||
po_to_json (>= 1.0.0)
|
||||
rails (>= 3.2.0)
|
||||
gherkin-ruby (0.3.2)
|
||||
gitaly-proto (0.62.0)
|
||||
gitaly-proto (0.64.0)
|
||||
google-protobuf (~> 3.1)
|
||||
grpc (~> 1.0)
|
||||
github-linguist (4.7.6)
|
||||
|
@ -1046,7 +1046,7 @@ DEPENDENCIES
|
|||
gettext (~> 3.2.2)
|
||||
gettext_i18n_rails (~> 1.8.0)
|
||||
gettext_i18n_rails_js (~> 1.2.0)
|
||||
gitaly-proto (~> 0.62.0)
|
||||
gitaly-proto (~> 0.64.0)
|
||||
github-linguist (~> 4.7.0)
|
||||
gitlab-flowdock-git-hook (~> 1.0.1)
|
||||
gitlab-markup (~> 1.6.2)
|
||||
|
|
|
@ -1661,6 +1661,7 @@ module Gitlab
|
|||
cmd = %W[#{Gitlab.config.git.bin_path} --git-dir=#{path} rev-list]
|
||||
cmd << "--after=#{options[:after].iso8601}" if options[:after]
|
||||
cmd << "--before=#{options[:before].iso8601}" if options[:before]
|
||||
cmd << "--max-count=#{options[:max_count]}" if options[:max_count]
|
||||
cmd += %W[--count #{options[:ref]}]
|
||||
cmd += %W[-- #{options[:path]}] if options[:path].present?
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ module Gitlab
|
|||
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 = options[:path] if options[:path].present?
|
||||
request.max_count = options[:max_count] if options[:max_count].present?
|
||||
|
||||
GitalyClient.call(@repository.storage, :commit_service, :count_commits, request, timeout: GitalyClient.medium_timeout).count
|
||||
end
|
||||
|
|
|
@ -1015,7 +1015,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
|||
shared_examples 'extended commit counting' do
|
||||
context 'with after timestamp' do
|
||||
it 'returns the number of commits after timestamp' do
|
||||
options = { ref: 'master', limit: nil, after: Time.iso8601('2013-03-03T20:15:01+00:00') }
|
||||
options = { ref: 'master', after: Time.iso8601('2013-03-03T20:15:01+00:00') }
|
||||
|
||||
expect(repository.count_commits(options)).to eq(25)
|
||||
end
|
||||
|
@ -1023,7 +1023,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
|||
|
||||
context 'with before timestamp' do
|
||||
it 'returns the number of commits before timestamp' do
|
||||
options = { ref: 'feature', limit: nil, before: Time.iso8601('2015-03-03T20:15:01+00:00') }
|
||||
options = { ref: 'feature', before: Time.iso8601('2015-03-03T20:15:01+00:00') }
|
||||
|
||||
expect(repository.count_commits(options)).to eq(9)
|
||||
end
|
||||
|
@ -1031,11 +1031,19 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
|||
|
||||
context 'with path' do
|
||||
it 'returns the number of commits with path ' do
|
||||
options = { ref: 'master', limit: nil, path: "encoding" }
|
||||
options = { ref: 'master', path: "encoding" }
|
||||
|
||||
expect(repository.count_commits(options)).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with max_count' do
|
||||
it 'returns the number of commits up to the passed limit' do
|
||||
options = { ref: 'master', max_count: 10, after: Time.iso8601('2013-03-03T20:15:01+00:00') }
|
||||
|
||||
expect(repository.count_commits(options)).to eq(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when Gitaly count_commits feature is enabled' do
|
||||
|
|
Loading…
Reference in New Issue