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
Boxiang Sun
gitlab-ce
Commits
33c950f2
Commit
33c950f2
authored
Jun 26, 2018
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client-side fix for Gitaly TreeEntry bug
parent
955f0ea5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
49 deletions
+30
-49
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+12
-29
lib/gitlab/gitaly_client/commit_service.rb
lib/gitlab/gitaly_client/commit_service.rb
+7
-0
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+11
-20
No files found.
lib/gitlab/git/commit.rb
View file @
33c950f2
...
@@ -493,13 +493,18 @@ module Gitlab
...
@@ -493,13 +493,18 @@ module Gitlab
def
tree_entry
(
path
)
def
tree_entry
(
path
)
return
unless
path
.
present?
return
unless
path
.
present?
@repository
.
gitaly_migrate
(
:commit_tree_entry
)
do
|
is_migrated
|
# We're only interested in metadata, so limit actual data to 1 byte
if
is_migrated
# since Gitaly doesn't support "send no data" option.
gitaly_tree_entry
(
path
)
entry
=
@repository
.
gitaly_commit_client
.
tree_entry
(
id
,
path
,
1
)
else
return
unless
entry
rugged_tree_entry
(
path
)
end
# To be compatible with the rugged format
end
entry
=
entry
.
to_h
entry
.
delete
(
:data
)
entry
[
:name
]
=
File
.
basename
(
path
)
entry
[
:type
]
=
entry
[
:type
].
downcase
entry
end
end
def
to_gitaly_commit
def
to_gitaly_commit
...
@@ -562,28 +567,6 @@ module Gitlab
...
@@ -562,28 +567,6 @@ module Gitlab
SERIALIZE_KEYS
SERIALIZE_KEYS
end
end
def
gitaly_tree_entry
(
path
)
# We're only interested in metadata, so limit actual data to 1 byte
# since Gitaly doesn't support "send no data" option.
entry
=
@repository
.
gitaly_commit_client
.
tree_entry
(
id
,
path
,
1
)
return
unless
entry
# To be compatible with the rugged format
entry
=
entry
.
to_h
entry
.
delete
(
:data
)
entry
[
:name
]
=
File
.
basename
(
path
)
entry
[
:type
]
=
entry
[
:type
].
downcase
entry
end
# Is this the same as Blob.find_entry_by_path ?
def
rugged_tree_entry
(
path
)
rugged_commit
.
tree
.
path
(
path
)
rescue
Rugged
::
TreeError
nil
end
def
gitaly_commit_author_from_rugged
(
author_or_committer
)
def
gitaly_commit_author_from_rugged
(
author_or_committer
)
Gitaly
::
CommitAuthor
.
new
(
Gitaly
::
CommitAuthor
.
new
(
name:
author_or_committer
[
:name
].
b
,
name:
author_or_committer
[
:name
].
b
,
...
...
lib/gitlab/gitaly_client/commit_service.rb
View file @
33c950f2
...
@@ -76,6 +76,13 @@ module Gitlab
...
@@ -76,6 +76,13 @@ module Gitlab
end
end
def
tree_entry
(
ref
,
path
,
limit
=
nil
)
def
tree_entry
(
ref
,
path
,
limit
=
nil
)
if
Pathname
.
new
(
path
).
cleanpath
.
to_s
.
start_with?
(
'../'
)
# The TreeEntry RPC should return an empty reponse in this case but in
# Gitaly 0.107.0 and earlier we get an exception instead. This early return
# saves us a Gitaly roundtrip while also avoiding the exception.
return
end
request
=
Gitaly
::
TreeEntryRequest
.
new
(
request
=
Gitaly
::
TreeEntryRequest
.
new
(
repository:
@gitaly_repo
,
repository:
@gitaly_repo
,
revision:
encode_binary
(
ref
),
revision:
encode_binary
(
ref
),
...
...
spec/models/commit_spec.rb
View file @
33c950f2
...
@@ -514,7 +514,6 @@ eos
...
@@ -514,7 +514,6 @@ eos
end
end
describe
'#uri_type'
do
describe
'#uri_type'
do
shared_examples
'URI type'
do
it
'returns the URI type at the given path'
do
it
'returns the URI type at the given path'
do
expect
(
commit
.
uri_type
(
'files/html'
)).
to
be
(
:tree
)
expect
(
commit
.
uri_type
(
'files/html'
)).
to
be
(
:tree
)
expect
(
commit
.
uri_type
(
'files/images/logo-black.png'
)).
to
be
(
:raw
)
expect
(
commit
.
uri_type
(
'files/images/logo-black.png'
)).
to
be
(
:raw
)
...
@@ -524,6 +523,7 @@ eos
...
@@ -524,6 +523,7 @@ eos
it
"returns nil if the path doesn't exists"
do
it
"returns nil if the path doesn't exists"
do
expect
(
commit
.
uri_type
(
'this/path/doesnt/exist'
)).
to
be_nil
expect
(
commit
.
uri_type
(
'this/path/doesnt/exist'
)).
to
be_nil
expect
(
commit
.
uri_type
(
'../path/doesnt/exist'
)).
to
be_nil
end
end
it
'is nil if the path is nil or empty'
do
it
'is nil if the path is nil or empty'
do
...
@@ -532,15 +532,6 @@ eos
...
@@ -532,15 +532,6 @@ eos
end
end
end
end
context
'when Gitaly commit_tree_entry feature is enabled'
do
it_behaves_like
'URI type'
end
context
'when Gitaly commit_tree_entry feature is disabled'
,
:disable_gitaly
do
it_behaves_like
'URI type'
end
end
describe
'.from_hash'
do
describe
'.from_hash'
do
let
(
:new_commit
)
{
described_class
.
from_hash
(
commit
.
to_hash
,
project
)
}
let
(
:new_commit
)
{
described_class
.
from_hash
(
commit
.
to_hash
,
project
)
}
...
...
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