Commit 87467127 authored by Maxim Rydkin's avatar Maxim Rydkin

replace `is_ancestor?` with `ancestor?`

parent 5f72aaa3
......@@ -49,7 +49,7 @@ class Deployment < ActiveRecord::Base
# created before then could have a `sha` referring to a commit that no
# longer exists in the repository, so just ignore those.
begin
project.repository.is_ancestor?(commit.id, sha)
project.repository.ancestor?(commit.id, sha)
rescue Rugged::OdbError
false
end
......
......@@ -944,7 +944,7 @@ class Repository
if branch_commit
same_head = branch_commit.id == root_ref_commit.id
!same_head && is_ancestor?(branch_commit.id, root_ref_commit.id)
!same_head && ancestor?(branch_commit.id, root_ref_commit.id)
else
nil
end
......@@ -958,12 +958,12 @@ class Repository
nil
end
def is_ancestor?(ancestor_id, descendant_id)
def ancestor?(ancestor_id, descendant_id)
return false if ancestor_id.nil? || descendant_id.nil?
Gitlab::GitalyClient.migrate(:is_ancestor) do |is_enabled|
if is_enabled
raw_repository.is_ancestor?(ancestor_id, descendant_id)
raw_repository.ancestor?(ancestor_id, descendant_id)
else
rugged_is_ancestor?(ancestor_id, descendant_id)
end
......
......@@ -439,7 +439,7 @@ module Gitlab
end
# Returns true is +from+ is direct ancestor to +to+, otherwise false
def is_ancestor?(from, to)
def ancestor?(from, to)
gitaly_commit_client.is_ancestor(from, to)
end
......
......@@ -2036,23 +2036,23 @@ describe Repository, models: true do
end
end
describe '#is_ancestor?' do
describe '#ancestor?' do
let(:commit) { repository.commit }
let(:ancestor) { commit.parents.first }
context 'with Gitaly enabled' do
it 'it is an ancestor' do
expect(repository.is_ancestor?(ancestor.id, commit.id)).to eq(true)
expect(repository.ancestor?(ancestor.id, commit.id)).to eq(true)
end
it 'it is not an ancestor' do
expect(repository.is_ancestor?(commit.id, ancestor.id)).to eq(false)
expect(repository.ancestor?(commit.id, ancestor.id)).to eq(false)
end
it 'returns false on nil-values' do
expect(repository.is_ancestor?(nil, commit.id)).to eq(false)
expect(repository.is_ancestor?(ancestor.id, nil)).to eq(false)
expect(repository.is_ancestor?(nil, nil)).to eq(false)
expect(repository.ancestor?(nil, commit.id)).to eq(false)
expect(repository.ancestor?(ancestor.id, nil)).to eq(false)
expect(repository.ancestor?(nil, nil)).to eq(false)
end
end
......@@ -2063,17 +2063,17 @@ describe Repository, models: true do
end
it 'it is an ancestor' do
expect(repository.is_ancestor?(ancestor.id, commit.id)).to eq(true)
expect(repository.ancestor?(ancestor.id, commit.id)).to eq(true)
end
it 'it is not an ancestor' do
expect(repository.is_ancestor?(commit.id, ancestor.id)).to eq(false)
expect(repository.ancestor?(commit.id, ancestor.id)).to eq(false)
end
it 'returns false on nil-values' do
expect(repository.is_ancestor?(nil, commit.id)).to eq(false)
expect(repository.is_ancestor?(ancestor.id, nil)).to eq(false)
expect(repository.is_ancestor?(nil, nil)).to eq(false)
expect(repository.ancestor?(nil, commit.id)).to eq(false)
expect(repository.ancestor?(ancestor.id, nil)).to eq(false)
expect(repository.ancestor?(nil, nil)).to eq(false)
end
end
end
......
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