Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
fe771b51
Commit
fe771b51
authored
Apr 11, 2017
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Gitaly::Commit#is_ancestor
- Upgrade Gitaly-version
parent
e5754535
Changes
5
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
app/models/repository.rb
app/models/repository.rb
+7
-9
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+5
-1
lib/gitlab/gitaly_client/commit.rb
lib/gitlab/gitaly_client/commit.rb
+17
-12
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+11
-13
No files found.
GITALY_SERVER_VERSION
View file @
fe771b51
0.
6
.0
0.
8
.0
app/models/repository.rb
View file @
fe771b51
...
@@ -961,15 +961,13 @@ class Repository
...
@@ -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?
...
...
lib/gitlab/git/repository.rb
View file @
fe771b51
...
@@ -451,7 +451,7 @@ module Gitlab
...
@@ -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
...
@@ -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
)
...
...
lib/gitlab/gitaly_client/commit.rb
View file @
fe771b51
...
@@ -5,6 +5,23 @@ module Gitlab
...
@@ -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
...
@@ -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
...
...
spec/models/repository_spec.rb
View file @
fe771b51
...
@@ -1849,17 +1849,15 @@ describe Repository, models: true do
...
@@ -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
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