Commit 681f5ef1 authored by Sushil Khanchi's avatar Sushil Khanchi 🐨
Browse files

CommitService: implement ListFiles

parent b5d928f1a8c6
......@@ -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:
......
......@@ -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) == []
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment