Skip to content

Commit

Permalink
Filter out annotated tags during clone.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Dec 28, 2016
1 parent 9785eb5 commit 549cbc3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion dulwich/porcelain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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')
Expand Down
5 changes: 3 additions & 2 deletions dulwich/refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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/')
4 changes: 3 additions & 1 deletion dulwich/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
extract_want_line_capabilities,
)
from dulwich.refs import (
ANNOTATED_TAG_SUFFIX,
write_info_refs,
)
from dulwich.repo import (
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 549cbc3

Please sign in to comment.