Commit f369da06 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Commits between in Gitaly only

Prior to this change, most the commits counted were done through Gitaly.
This removes the last point where this wasn't the case.

This makes the `rugged_count_commits` method obsolete, with its tests.

Closes https://gitlab.com/gitlab-org/gitaly/issues/315
parent 941756c5
...@@ -116,15 +116,9 @@ module Gitlab ...@@ -116,15 +116,9 @@ module Gitlab
# Commit.between(repo, '29eda46b', 'master') # Commit.between(repo, '29eda46b', 'master')
# #
def between(repo, base, head) def between(repo, base, head)
Gitlab::GitalyClient.migrate(:commits_between) do |is_enabled| repo.wrapped_gitaly_errors do
if is_enabled repo.gitaly_commit_client.between(base, head)
repo.gitaly_commit_client.between(base, head)
else
repo.rugged_commits_between(base, head).map { |c| decorate(repo, c) }
end
end end
rescue Rugged::ReferenceError
[]
end end
# Returns commits collection # Returns commits collection
......
...@@ -492,27 +492,6 @@ module Gitlab ...@@ -492,27 +492,6 @@ module Gitlab
Ref.dereference_object(obj) Ref.dereference_object(obj)
end end
# Return a collection of Rugged::Commits between the two revspec arguments.
# See http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
# a detailed list of valid arguments.
#
# Gitaly note: JV: to be deprecated in favor of Commit.between
def rugged_commits_between(from, to)
walker = Rugged::Walker.new(rugged)
walker.sorting(Rugged::SORT_NONE | Rugged::SORT_REVERSE)
sha_from = sha_from_ref(from)
sha_to = sha_from_ref(to)
walker.push(sha_to)
walker.hide(sha_from)
commits = walker.to_a
walker.reset
commits
end
# Counts the amount of commits between `from` and `to`. # Counts the amount of commits between `from` and `to`.
def count_commits_between(from, to, options = {}) def count_commits_between(from, to, options = {})
count_commits(from: from, to: to, **options) count_commits(from: from, to: to, **options)
......
...@@ -996,46 +996,6 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -996,46 +996,6 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
end end
describe "#rugged_commits_between" do
around do |example|
# TODO #rugged_commits_between will be removed, has been migrated to gitaly
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
example.run
end
end
context 'two SHAs' do
let(:first_sha) { 'b0e52af38d7ea43cf41d8a6f2471351ac036d6c9' }
let(:second_sha) { '0e50ec4d3c7ce42ab74dda1d422cb2cbffe1e326' }
it 'returns the number of commits between' do
expect(repository.rugged_commits_between(first_sha, second_sha).count).to eq(3)
end
end
context 'SHA and master branch' do
let(:sha) { 'b0e52af38d7ea43cf41d8a6f2471351ac036d6c9' }
let(:branch) { 'master' }
it 'returns the number of commits between a sha and a branch' do
expect(repository.rugged_commits_between(sha, branch).count).to eq(5)
end
it 'returns the number of commits between a branch and a sha' do
expect(repository.rugged_commits_between(branch, sha).count).to eq(0) # sha is before branch
end
end
context 'two branches' do
let(:first_branch) { 'feature' }
let(:second_branch) { 'master' }
it 'returns the number of commits between' do
expect(repository.rugged_commits_between(first_branch, second_branch).count).to eq(17)
end
end
end
describe '#count_commits_between' do describe '#count_commits_between' do
subject { repository.count_commits_between('feature', 'master') } subject { repository.count_commits_between('feature', 'master') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment