diff --git a/dulwich/porcelain.py b/dulwich/porcelain.py index 8a07d9cad..cab02ed6c 100644 --- a/dulwich/porcelain.py +++ b/dulwich/porcelain.py @@ -101,6 +101,7 @@ Protocol, ZERO_SHA, ) +from dulwich.refs import ANNOTATED_TAG_SUFFIX from dulwich.repo import (BaseRepo, Repo) from dulwich.server import ( FileSystemBackend, @@ -278,7 +279,8 @@ def clone(source, target=None, bare=False, checkout=None, r.refs.import_refs( b'refs/tags', {n[len(b'refs/tags/'):]: v for (n, v) in remote_refs.items() - if n.startswith(b'refs/tags/') and not n.endswith(b'^{}')}) + if n.startswith(b'refs/tags/') and + not n.endswith(ANNOTATED_TAG_SUFFIX)}) r[b"HEAD"] = remote_refs[b"HEAD"] if checkout: errstream.write(b'Checking out HEAD\n') diff --git a/dulwich/refs.py b/dulwich/refs.py index 841874959..fcb6eca5d 100644 --- a/dulwich/refs.py +++ b/dulwich/refs.py @@ -44,6 +44,7 @@ SYMREF = b'ref: ' LOCAL_BRANCH_PREFIX = b'refs/heads/' BAD_REF_CHARS = set(b'\177 ~^:?*[') +ANNOTATED_TAG_SUFFIX = b'^{}' def check_ref_format(refname): @@ -374,7 +375,7 @@ def __init__(self, f): self._peeled = {} for l in f.readlines(): sha, name = l.rstrip(b'\n').split(b'\t') - if name.endswith(b'^{}'): + if name.endswith(ANNOTATED_TAG_SUFFIX): name = name[:-3] if not check_ref_format(name): raise ValueError("invalid ref name %r" % name) @@ -782,7 +783,7 @@ def write_info_refs(refs, store): peeled = store.peel_sha(sha) yield o.id + b'\t' + name + b'\n' if o.id != peeled.id: - yield peeled.id + b'\t' + name + b'^{}\n' + yield peeled.id + b'\t' + name + ANNOTATED_TAG_SUFFIX + b'\n' is_local_branch = lambda x: x.startswith(b'refs/heads/') diff --git a/dulwich/server.py b/dulwich/server.py index e08884439..9e5d6ec41 100644 --- a/dulwich/server.py +++ b/dulwich/server.py @@ -106,6 +106,7 @@ extract_want_line_capabilities, ) from dulwich.refs import ( + ANNOTATED_TAG_SUFFIX, write_info_refs, ) from dulwich.repo import ( @@ -537,7 +538,8 @@ def determine_wants(self, heads): self.proto.write_pkt_line(line + b'\n') peeled_sha = self.get_peeled(ref) if peeled_sha != sha: - self.proto.write_pkt_line(peeled_sha + b' ' + ref + b'^{}\n') + self.proto.write_pkt_line( + peeled_sha + b' ' + ref + ANNOTATED_TAG_SUFFIX + b'\n') # i'm done.. self.proto.write_pkt_line(None)