Skip to content
Snippets Groups Projects
Commit 7825274a authored by Georges Racinet's avatar Georges Racinet
Browse files

RefService: FindAllBranchNames must return refs

Despite its name, the expected return value of `FindAllBranchNames`
is actually full Git refs, such as `refs/heads/git_branch_name`.
parent 074d3245
No related branches found
No related tags found
1 merge request!3RefService: FindAllBranchNames must return refs
Pipeline #10109 passed
......@@ -13,6 +13,7 @@
branchmap_branch_from_gitlab_branch,
gitlab_branch_from_branchmap_branch,
parse_wild_gitlab_branch,
gitlab_branch_ref,
)
......@@ -103,3 +104,9 @@
for key, node in pycompat.iteritems(repo._bookmarks):
yield key, repo[node]
def iter_gitlab_branches_as_refs(repo):
"""Same as :func:`iter_gitlab_branches`, yielding full Git refs."""
for branch, ctx in iter_gitlab_branches(repo):
yield gitlab_branch_ref(branch), ctx
......@@ -61,6 +61,7 @@
from ..branch import (
gitlab_branch_head,
iter_gitlab_branches,
iter_gitlab_branches_as_refs,
)
from .. import message
from ..servicer import HGitalyServicer
......@@ -97,7 +98,7 @@
request: FindAllBranchNamesRequest,
context) -> FindAllBranchNamesResponse:
repo = self.load_repo(request.repository)
for chunk in chunked(iter_gitlab_branches(repo)):
for chunk in chunked(iter_gitlab_branches_as_refs(repo)):
yield FindAllBranchNamesResponse(names=(br[0] for br in chunk))
def FindAllTagNames(self,
......
......@@ -46,7 +46,10 @@
resp = ref_stub.FindAllBranchNames(request)
assert [set(chunk.names) for chunk in resp] == [
{b'branch/default', b'branch/other', b'topic/default/zz-top'}]
{b'refs/heads/branch/default',
b'refs/heads/branch/other',
b'refs/heads/topic/default/zz-top',
}]
def test_find_all_branch_names_chunks(grpc_channel, server_repos_root):
......@@ -64,7 +67,7 @@
assert len(chunks[0].names) == 20
assert len(chunks[1].names) == 2
assert set(name for chunk in chunks for name in chunk.names) == {
b'branch/br%d' % i for i in range(22)}
b'refs/heads/branch/br%d' % i for i in range(22)}
def test_tags(grpc_channel, server_repos_root):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment