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
7b108850
Commit
7b108850
authored
Aug 04, 2017
by
Kim "BKC" Carlbäcker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Git::Repository.ls_files to Gitaly
parent
932a6e69
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
23 deletions
+49
-23
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+36
-22
lib/gitlab/gitaly_client/commit_service.rb
lib/gitlab/gitaly_client/commit_service.rb
+12
-0
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+1
-1
No files found.
lib/gitlab/git/repository.rb
View file @
7b108850
...
@@ -603,29 +603,13 @@ module Gitlab
...
@@ -603,29 +603,13 @@ module Gitlab
#
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/327
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/327
def
ls_files
(
ref
)
def
ls_files
(
ref
)
actual_ref
=
ref
||
root_ref
gitaly_migrate
(
:ls_files
)
do
|
is_enabled
|
if
is_enabled
begin
gitaly_ls_files
(
ref
)
sha_from_ref
(
actual_ref
)
else
rescue
Rugged
::
OdbError
,
Rugged
::
InvalidError
,
Rugged
::
ReferenceError
git_ls_files
(
ref
)
# Return an empty array if the ref wasn't found
return
[]
end
end
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
ls-tree)
cmd
+=
%w(-r)
cmd
+=
%w(--full-tree)
cmd
+=
%w(--full-name)
cmd
+=
%W(--
#{
actual_ref
}
)
raw_output
=
IO
.
popen
(
cmd
,
&
:read
).
split
(
"
\n
"
).
map
do
|
f
|
stuff
,
path
=
f
.
split
(
"
\t
"
)
_mode
,
type
,
_sha
=
stuff
.
split
(
" "
)
path
if
type
==
"blob"
# Contain only blob type
end
end
raw_output
.
compact
end
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/328
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/328
...
@@ -973,6 +957,36 @@ module Gitlab
...
@@ -973,6 +957,36 @@ module Gitlab
raw_output
.
to_i
raw_output
.
to_i
end
end
def
gitaly_ls_files
(
ref
)
gitaly_commit_client
.
ls_files
(
ref
)
end
def
git_ls_files
(
ref
)
actual_ref
=
ref
||
root_ref
begin
sha_from_ref
(
actual_ref
)
rescue
Rugged
::
OdbError
,
Rugged
::
InvalidError
,
Rugged
::
ReferenceError
# Return an empty array if the ref wasn't found
return
[]
end
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
ls-tree)
cmd
+=
%w(-r)
cmd
+=
%w(--full-tree)
cmd
+=
%w(--full-name)
cmd
+=
%W(--
#{
actual_ref
}
)
raw_output
=
IO
.
popen
(
cmd
,
&
:read
).
split
(
"
\n
"
).
map
do
|
f
|
stuff
,
path
=
f
.
split
(
"
\t
"
)
_mode
,
type
,
_sha
=
stuff
.
split
(
" "
)
path
if
type
==
"blob"
# Contain only blob type
end
raw_output
.
compact
end
end
end
end
end
end
end
lib/gitlab/gitaly_client/commit_service.rb
View file @
7b108850
...
@@ -10,6 +10,18 @@ module Gitlab
...
@@ -10,6 +10,18 @@ module Gitlab
@repository
=
repository
@repository
=
repository
end
end
def
ls_files
(
revision
)
request
=
Gitaly
::
ListFilesRequest
.
new
(
repository:
@gitaly_repo
,
revision:
GitalyClient
.
encode
(
revision
)
)
response
=
GitalyClient
.
call
(
@repository
.
storage
,
:commit_service
,
:list_files
,
request
)
response
.
flat_map
do
|
msg
|
msg
.
paths
.
map
{
|
d
|
d
.
dup
.
force_encoding
(
Encoding
::
UTF_8
)
}
end
end
def
is_ancestor
(
ancestor_id
,
child_id
)
def
is_ancestor
(
ancestor_id
,
child_id
)
request
=
Gitaly
::
CommitIsAncestorRequest
.
new
(
request
=
Gitaly
::
CommitIsAncestorRequest
.
new
(
repository:
@gitaly_repo
,
repository:
@gitaly_repo
,
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
7b108850
...
@@ -1002,7 +1002,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -1002,7 +1002,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect
(
master_file_paths
).
to
include
(
"files/html/500.html"
)
expect
(
master_file_paths
).
to
include
(
"files/html/500.html"
)
end
end
it
"do
se
not read submodule directory and empty directory of master branch"
do
it
"do
es
not read submodule directory and empty directory of master branch"
do
expect
(
master_file_paths
).
not_to
include
(
"six"
)
expect
(
master_file_paths
).
not_to
include
(
"six"
)
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