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

ref service: DeleteRefs, refusing to perform

We could want a different behaviour later on:

- silently ignoring the request (for now we're happy to have
  errors as a bug catcher)
- close branches if that is relevant (but perhaps we'll want
  a new rpc call for that).
parent 1bcc4d2e
No related branches found
No related tags found
No related merge requests found
Pipeline #7120 passed with warnings
......@@ -36,6 +36,8 @@
RefExistsResponse,
FindBranchRequest,
FindBranchResponse,
DeleteRefsRequest,
DeleteRefsResponse,
)
from ..stub.ref_pb2_grpc import RefServiceServicer
......@@ -197,6 +199,12 @@
return FindBranchResponse(
branch=Branch(name=name, target_commit=message.commit(head)))
def DeleteRefs(self,
request: DeleteRefsRequest,
context) -> DeleteRefsResponse:
return DeleteRefsResponse(
git_error="Refs cannot be manually deleted in Mercurial")
def flbr_author(commit: GitCommit):
"""Extract commit intro specific fields of FindLocalBranchCommitAuthor."""
......
......@@ -14,6 +14,7 @@
FindLocalBranchesRequest,
FindAllRemoteBranchesRequest,
FindAllBranchesRequest,
DeleteRefsRequest,
)
from ..stub.ref_pb2_grpc import RefServiceStub
......@@ -141,3 +142,15 @@
# although we could resolve the hexadecimal node id from any
# "wild" branch ref, it is just wrong to pretend it exists.
assert not ref_exists(b'refs/heads/wild/' + ctx.hex())
def test_delete_refs(grpc_channel, server_repos_root):
ref_stub = RefServiceStub(grpc_channel)
wrapper, grpc_repo = make_empty_repo(server_repos_root,
relative_path='delete_refs')
# Let's make it clear failures are not due to missing branches
wrapper.write_commit('foo')
resp = ref_stub.DeleteRefs(DeleteRefsRequest(repository=grpc_repo,
refs=[b'branch/default']))
assert resp.git_error
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