parent
e57545351b
commit
fe771b51fd
|
|
@ -1 +1 @@
|
||||||
0.6.0
|
0.8.0
|
||||||
|
|
|
||||||
|
|
@ -961,15 +961,13 @@ class Repository
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_ancestor?(ancestor_id, descendant_id)
|
def is_ancestor?(ancestor_id, descendant_id)
|
||||||
# NOTE: This feature is intentionally disabled until
|
Gitlab::GitalyClient.migrate(:is_ancestor) do |is_enabled|
|
||||||
# https://gitlab.com/gitlab-org/gitlab-ce/issues/30586 is resolved
|
if is_enabled
|
||||||
# Gitlab::GitalyClient.migrate(:is_ancestor) do |is_enabled|
|
raw_repository.is_ancestor?(ancestor_id, descendant_id)
|
||||||
# if is_enabled
|
else
|
||||||
# raw_repository.is_ancestor?(ancestor_id, descendant_id)
|
merge_base_commit(ancestor_id, descendant_id) == ancestor_id
|
||||||
# else
|
end
|
||||||
merge_base_commit(ancestor_id, descendant_id) == ancestor_id
|
end
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def empty_repo?
|
def empty_repo?
|
||||||
|
|
|
||||||
|
|
@ -451,7 +451,7 @@ module Gitlab
|
||||||
|
|
||||||
# Returns true is +from+ is direct ancestor to +to+, otherwise false
|
# Returns true is +from+ is direct ancestor to +to+, otherwise false
|
||||||
def is_ancestor?(from, to)
|
def is_ancestor?(from, to)
|
||||||
Gitlab::GitalyClient::Commit.is_ancestor(self, from, to)
|
gitaly_commit_client.is_ancestor(from, to)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return an array of Diff objects that represent the diff
|
# Return an array of Diff objects that represent the diff
|
||||||
|
|
@ -1273,6 +1273,10 @@ module Gitlab
|
||||||
@gitaly_ref_client ||= Gitlab::GitalyClient::Ref.new(self)
|
@gitaly_ref_client ||= Gitlab::GitalyClient::Ref.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def gitaly_commit_client
|
||||||
|
@gitaly_commit_client ||= Gitlab::GitalyClient::Commit.new(self)
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the `Rugged` sorting type constant for a given
|
# Returns the `Rugged` sorting type constant for a given
|
||||||
# sort type key. Valid keys are `:none`, `:topo`, and `:date`
|
# sort type key. Valid keys are `:none`, `:topo`, and `:date`
|
||||||
def rugged_sort_type(key)
|
def rugged_sort_type(key)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,23 @@ module Gitlab
|
||||||
# See http://stackoverflow.com/a/40884093/1856239 and https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012
|
# See http://stackoverflow.com/a/40884093/1856239 and https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012
|
||||||
EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze
|
EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze
|
||||||
|
|
||||||
|
attr_accessor :stub
|
||||||
|
|
||||||
|
def initialize(repository)
|
||||||
|
@gitaly_repo = repository.gitaly_repository
|
||||||
|
@stub = Gitaly::Commit::Stub.new(nil, nil, channel_override: repository.gitaly_channel)
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_ancestor(ancestor_id, child_id)
|
||||||
|
request = Gitaly::CommitIsAncestorRequest.new(
|
||||||
|
repository: @gitaly_repo,
|
||||||
|
ancestor_id: ancestor_id,
|
||||||
|
child_id: child_id
|
||||||
|
)
|
||||||
|
|
||||||
|
@stub.commit_is_ancestor(request).value
|
||||||
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def diff_from_parent(commit, options = {})
|
def diff_from_parent(commit, options = {})
|
||||||
repository = commit.project.repository
|
repository = commit.project.repository
|
||||||
|
|
@ -20,18 +37,6 @@ module Gitlab
|
||||||
|
|
||||||
Gitlab::Git::DiffCollection.new(stub.commit_diff(request), options)
|
Gitlab::Git::DiffCollection.new(stub.commit_diff(request), options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_ancestor(repository, ancestor_id, child_id)
|
|
||||||
gitaly_repo = repository.gitaly_repository
|
|
||||||
stub = Gitaly::Commit::Stub.new(nil, nil, channel_override: repository.gitaly_channel)
|
|
||||||
request = Gitaly::CommitIsAncestorRequest.new(
|
|
||||||
repository: gitaly_repo,
|
|
||||||
ancestor_id: ancestor_id,
|
|
||||||
child_id: child_id
|
|
||||||
)
|
|
||||||
|
|
||||||
stub.commit_is_ancestor(request).value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1849,17 +1849,15 @@ describe Repository, models: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Uncomment when feature is reenabled
|
describe '#is_ancestor?' do
|
||||||
# describe '#is_ancestor?' do
|
context 'Gitaly is_ancestor feature enabled' do
|
||||||
# context 'Gitaly is_ancestor feature enabled' do
|
it "asks Gitaly server if it's an ancestor" do
|
||||||
# it 'asks Gitaly server if it\'s an ancestor' do
|
commit = repository.commit
|
||||||
# commit = repository.commit
|
expect(repository.raw_repository).to receive(:is_ancestor?).and_call_original
|
||||||
# allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:is_ancestor).and_return(true)
|
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:is_ancestor).and_return(true)
|
||||||
# expect(Gitlab::GitalyClient::Commit).to receive(:is_ancestor).
|
|
||||||
# with(repository.raw_repository, commit.id, commit.id).and_return(true)
|
expect(repository.is_ancestor?(commit.id, commit.id)).to be true
|
||||||
#
|
end
|
||||||
# expect(repository.is_ancestor?(commit.id, commit.id)).to be true
|
end
|
||||||
# end
|
end
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue