Add support for :all option to {count,find}_commits
This commit is contained in:
parent
cbefd38f9c
commit
cd770946c4
6 changed files with 249 additions and 241 deletions
|
@ -1 +1 @@
|
||||||
0.87.0
|
0.88.0
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -411,7 +411,7 @@ group :ed25519 do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gitaly GRPC client
|
# Gitaly GRPC client
|
||||||
gem 'gitaly-proto', '~> 0.87.0', require: 'gitaly'
|
gem 'gitaly-proto', '~> 0.88.0', require: 'gitaly'
|
||||||
# Locked until https://github.com/google/protobuf/issues/4210 is closed
|
# Locked until https://github.com/google/protobuf/issues/4210 is closed
|
||||||
gem 'google-protobuf', '= 3.5.1'
|
gem 'google-protobuf', '= 3.5.1'
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ GEM
|
||||||
po_to_json (>= 1.0.0)
|
po_to_json (>= 1.0.0)
|
||||||
rails (>= 3.2.0)
|
rails (>= 3.2.0)
|
||||||
gherkin-ruby (0.3.2)
|
gherkin-ruby (0.3.2)
|
||||||
gitaly-proto (0.87.0)
|
gitaly-proto (0.88.0)
|
||||||
google-protobuf (~> 3.1)
|
google-protobuf (~> 3.1)
|
||||||
grpc (~> 1.0)
|
grpc (~> 1.0)
|
||||||
github-linguist (5.3.3)
|
github-linguist (5.3.3)
|
||||||
|
@ -1057,7 +1057,7 @@ DEPENDENCIES
|
||||||
gettext (~> 3.2.2)
|
gettext (~> 3.2.2)
|
||||||
gettext_i18n_rails (~> 1.8.0)
|
gettext_i18n_rails (~> 1.8.0)
|
||||||
gettext_i18n_rails_js (~> 1.2.0)
|
gettext_i18n_rails_js (~> 1.2.0)
|
||||||
gitaly-proto (~> 0.87.0)
|
gitaly-proto (~> 0.88.0)
|
||||||
github-linguist (~> 5.3.3)
|
github-linguist (~> 5.3.3)
|
||||||
gitlab-flowdock-git-hook (~> 1.0.1)
|
gitlab-flowdock-git-hook (~> 1.0.1)
|
||||||
gitlab-markup (~> 1.6.2)
|
gitlab-markup (~> 1.6.2)
|
||||||
|
|
|
@ -479,9 +479,8 @@ module Gitlab
|
||||||
raise ArgumentError.new("invalid Repository#log limit: #{limit.inspect}")
|
raise ArgumentError.new("invalid Repository#log limit: #{limit.inspect}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO support options[:all] in Gitaly https://gitlab.com/gitlab-org/gitaly/issues/1049
|
|
||||||
gitaly_migrate(:find_commits) do |is_enabled|
|
gitaly_migrate(:find_commits) do |is_enabled|
|
||||||
if is_enabled && !options[:all]
|
if is_enabled
|
||||||
gitaly_commit_client.find_commits(options)
|
gitaly_commit_client.find_commits(options)
|
||||||
else
|
else
|
||||||
raw_log(options).map { |c| Commit.decorate(self, c) }
|
raw_log(options).map { |c| Commit.decorate(self, c) }
|
||||||
|
@ -508,9 +507,8 @@ module Gitlab
|
||||||
def count_commits(options)
|
def count_commits(options)
|
||||||
count_commits_options = process_count_commits_options(options)
|
count_commits_options = process_count_commits_options(options)
|
||||||
|
|
||||||
# TODO add support for options[:all] in Gitaly https://gitlab.com/gitlab-org/gitaly/issues/1050
|
|
||||||
gitaly_migrate(:count_commits) do |is_enabled|
|
gitaly_migrate(:count_commits) do |is_enabled|
|
||||||
if is_enabled && !options[:all]
|
if is_enabled
|
||||||
count_commits_by_gitaly(count_commits_options)
|
count_commits_by_gitaly(count_commits_options)
|
||||||
else
|
else
|
||||||
count_commits_by_shelling_out(count_commits_options)
|
count_commits_by_shelling_out(count_commits_options)
|
||||||
|
|
|
@ -134,7 +134,8 @@ module Gitlab
|
||||||
def commit_count(ref, options = {})
|
def commit_count(ref, options = {})
|
||||||
request = Gitaly::CountCommitsRequest.new(
|
request = Gitaly::CountCommitsRequest.new(
|
||||||
repository: @gitaly_repo,
|
repository: @gitaly_repo,
|
||||||
revision: encode_binary(ref)
|
revision: encode_binary(ref),
|
||||||
|
all: !!options[:all]
|
||||||
)
|
)
|
||||||
request.after = Google::Protobuf::Timestamp.new(seconds: options[:after].to_i) if options[:after].present?
|
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.before = Google::Protobuf::Timestamp.new(seconds: options[:before].to_i) if options[:before].present?
|
||||||
|
@ -269,6 +270,7 @@ module Gitlab
|
||||||
offset: options[:offset],
|
offset: options[:offset],
|
||||||
follow: options[:follow],
|
follow: options[:follow],
|
||||||
skip_merges: options[:skip_merges],
|
skip_merges: options[:skip_merges],
|
||||||
|
all: !!options[:all],
|
||||||
disable_walk: true # This option is deprecated. The 'walk' implementation is being removed.
|
disable_walk: true # This option is deprecated. The 'walk' implementation is being removed.
|
||||||
)
|
)
|
||||||
request.after = GitalyClient.timestamp(options[:after]) if options[:after]
|
request.after = GitalyClient.timestamp(options[:after]) if options[:after]
|
||||||
|
|
|
@ -751,6 +751,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#log" do
|
describe "#log" do
|
||||||
|
shared_examples 'repository log' do
|
||||||
let(:commit_with_old_name) do
|
let(:commit_with_old_name) do
|
||||||
Gitlab::Git::Commit.decorate(repository, @commit_with_old_name_id)
|
Gitlab::Git::Commit.decorate(repository, @commit_with_old_name_id)
|
||||||
end
|
end
|
||||||
|
@ -993,16 +994,23 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with all' do
|
context 'with all' do
|
||||||
let(:options) { { all: true, limit: 50 } }
|
|
||||||
|
|
||||||
it 'returns a list of commits' do
|
it 'returns a list of commits' do
|
||||||
commits = repository.log(options)
|
commits = repository.log({ all: true, limit: 50 })
|
||||||
|
|
||||||
expect(commits.size).to eq(37)
|
expect(commits.size).to eq(37)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when Gitaly find_commits feature is enabled' do
|
||||||
|
it_behaves_like 'repository log'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when Gitaly find_commits feature is disabled', :disable_gitaly do
|
||||||
|
it_behaves_like 'repository log'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#rugged_commits_between" do
|
describe "#rugged_commits_between" do
|
||||||
context 'two SHAs' do
|
context 'two SHAs' do
|
||||||
let(:first_sha) { 'b0e52af38d7ea43cf41d8a6f2471351ac036d6c9' }
|
let(:first_sha) { 'b0e52af38d7ea43cf41d8a6f2471351ac036d6c9' }
|
||||||
|
@ -1136,14 +1144,6 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
||||||
expect(repository.count_commits(options)).to eq(10)
|
expect(repository.count_commits(options)).to eq(10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context 'when Gitaly count_commits feature is enabled' do
|
|
||||||
it_behaves_like 'extended commit counting'
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when Gitaly count_commits feature is disabled', :skip_gitaly_mock do
|
|
||||||
it_behaves_like 'extended commit counting'
|
|
||||||
|
|
||||||
context "with all" do
|
context "with all" do
|
||||||
it "returns the number of commits in the whole repository" do
|
it "returns the number of commits in the whole repository" do
|
||||||
|
@ -1155,10 +1155,18 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
||||||
|
|
||||||
context 'without all or ref being specified' do
|
context 'without all or ref being specified' do
|
||||||
it "raises an ArgumentError" do
|
it "raises an ArgumentError" do
|
||||||
expect { repository.count_commits({}) }.to raise_error(ArgumentError, "Please specify a valid ref or set the 'all' attribute to true")
|
expect { repository.count_commits({}) }.to raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when Gitaly count_commits feature is enabled' do
|
||||||
|
it_behaves_like 'extended commit counting'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when Gitaly count_commits feature is disabled', :disable_gitaly do
|
||||||
|
it_behaves_like 'extended commit counting'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#autocrlf' do
|
describe '#autocrlf' do
|
||||||
|
|
Loading…
Reference in a new issue