BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3f8ead1a
Commit
3f8ead1a
authored
May 01, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '30586-fix-gitaly-is-ancestor' into 'master'
Fix Gitaly::Commit#is_ancestor Closes #30586 See merge request !10634
parents
d4aeda20
fe771b51
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
36 deletions
+41
-36
GITALY_SERVER_VERSION
GITALY_SERVER_VERSION
+1
-1
repository.rb
app/models/repository.rb
+7
-9
repository.rb
lib/gitlab/git/repository.rb
+5
-1
commit.rb
lib/gitlab/gitaly_client/commit.rb
+17
-12
repository_spec.rb
spec/models/repository_spec.rb
+11
-13
No files found.
GITALY_SERVER_VERSION
View file @
3f8ead1a
0.
6
.0
0.
8
.0
app/models/repository.rb
View file @
3f8ead1a
...
...
@@ -961,15 +961,13 @@ class Repository
end
def
is_ancestor?
(
ancestor_id
,
descendant_id
)
# NOTE: This feature is intentionally disabled until
# https://gitlab.com/gitlab-org/gitlab-ce/issues/30586 is resolved
# Gitlab::GitalyClient.migrate(:is_ancestor) do |is_enabled|
# if is_enabled
# raw_repository.is_ancestor?(ancestor_id, descendant_id)
# else
merge_base_commit
(
ancestor_id
,
descendant_id
)
==
ancestor_id
# end
# end
Gitlab
::
GitalyClient
.
migrate
(
:is_ancestor
)
do
|
is_enabled
|
if
is_enabled
raw_repository
.
is_ancestor?
(
ancestor_id
,
descendant_id
)
else
merge_base_commit
(
ancestor_id
,
descendant_id
)
==
ancestor_id
end
end
end
def
empty_repo?
...
...
lib/gitlab/git/repository.rb
View file @
3f8ead1a
...
...
@@ -451,7 +451,7 @@ module Gitlab
# Returns true is +from+ is direct ancestor to +to+, otherwise false
def
is_ancestor?
(
from
,
to
)
Gitlab
::
GitalyClient
::
Commit
.
is_ancestor
(
self
,
from
,
to
)
gitaly_commit_client
.
is_ancestor
(
from
,
to
)
end
# Return an array of Diff objects that represent the diff
...
...
@@ -1273,6 +1273,10 @@ module Gitlab
@gitaly_ref_client
||=
Gitlab
::
GitalyClient
::
Ref
.
new
(
self
)
end
def
gitaly_commit_client
@gitaly_commit_client
||=
Gitlab
::
GitalyClient
::
Commit
.
new
(
self
)
end
# Returns the `Rugged` sorting type constant for a given
# sort type key. Valid keys are `:none`, `:topo`, and `:date`
def
rugged_sort_type
(
key
)
...
...
lib/gitlab/gitaly_client/commit.rb
View file @
3f8ead1a
...
...
@@ -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
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
def
diff_from_parent
(
commit
,
options
=
{})
repository
=
commit
.
project
.
repository
...
...
@@ -20,18 +37,6 @@ module Gitlab
Gitlab
::
Git
::
DiffCollection
.
new
(
stub
.
commit_diff
(
request
),
options
)
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
...
...
spec/models/repository_spec.rb
View file @
3f8ead1a
...
...
@@ -1849,17 +1849,15 @@ describe Repository, models: true do
end
end
# TODO: Uncomment when feature is reenabled
# describe '#is_ancestor?' do
# context 'Gitaly is_ancestor feature enabled' do
# it 'asks Gitaly server if it\'s an ancestor' do
# commit = repository.commit
# 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
# end
# end
describe
'#is_ancestor?'
do
context
'Gitaly is_ancestor feature enabled'
do
it
"asks Gitaly server if it's an ancestor"
do
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
)
expect
(
repository
.
is_ancestor?
(
commit
.
id
,
commit
.
id
)).
to
be
true
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment