Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
hgitaly
Commits
681f5ef1f8ce
Commit
681f5ef1
authored
Mar 16, 2021
by
Sushil Khanchi
🐨
Browse files
CommitService: implement ListFiles
parent
b5d928f1a8c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
hgitaly/service/commit.py
View file @
681f5ef1
...
...
@@ -237,8 +237,15 @@
def
ListFiles
(
self
,
request
:
ListFilesRequest
,
context
)
->
ListFilesResponse
:
return
not_implemented
(
context
,
ListFilesResponse
,
issue
=
13
)
# pragma no cover
repo
=
self
.
load_repo
(
request
.
repository
,
context
)
revision
=
pycompat
.
sysbytes
(
request
.
revision
)
logger
.
debug
(
"ListFiles revision=%r"
,
revision
)
ctx
=
gitlab_revision_changeset
(
repo
,
revision
)
if
ctx
is
None
:
return
mf
=
ctx
.
manifest
()
for
paths
in
chunked
(
mf
.
iterkeys
()):
yield
ListFilesResponse
(
paths
=
paths
)
def
CommitStats
(
self
,
request
:
CommitStatsRequest
,
context
)
->
CommitStatsResponse
:
...
...
hgitaly/service/tests/test_commit.py
View file @
681f5ef1
...
...
@@ -32,6 +32,7 @@
LastCommitForPathRequest
,
ListCommitsByOidRequest
,
ListCommitsByRefNameRequest
,
ListFilesRequest
,
ListLastCommitsForTreeRequest
,
RawBlameRequest
,
)
...
...
@@ -813,3 +814,28 @@
do_rpc
(
sha0
,
b
''
)
assert
exc_info
.
value
.
code
()
==
grpc
.
StatusCode
.
INVALID_ARGUMENT
assert
'RawBlame: empty Path'
in
exc_info
.
value
.
details
()
def
test_list_files
(
grpc_channel
,
server_repos_root
):
grpc_stub
=
CommitServiceStub
(
grpc_channel
)
wrapper
,
grpc_repo
=
make_empty_repo
(
server_repos_root
)
sha0
=
wrapper
.
commit_file
(
'foo'
).
hex
()
sha1
=
wrapper
.
commit_file
(
'bar'
).
hex
()
sha2
=
wrapper
.
commit_file
(
'zoo'
).
hex
()
def
do_rpc
(
rev
):
request
=
ListFilesRequest
(
repository
=
grpc_repo
,
revision
=
rev
)
response
=
grpc_stub
.
ListFiles
(
request
)
final
=
[]
for
resp
in
response
:
final
.
extend
(
resp
.
paths
)
return
final
assert
do_rpc
(
sha0
)
==
[
b
'foo'
]
assert
do_rpc
(
sha1
)
==
[
b
'bar'
,
b
'foo'
]
assert
do_rpc
(
sha2
)
==
[
b
'bar'
,
b
'foo'
,
b
'zoo'
]
# with unknown revision
assert
do_rpc
(
b
"23fire32"
*
5
)
==
[]
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