Browse Source

Filter out annotated tags during clone.

Jelmer Vernooij 8 years ago
parent
commit
549cbc312f
3 changed files with 9 additions and 4 deletions
  1. 3 1
      dulwich/porcelain.py
  2. 3 2
      dulwich/refs.py
  3. 3 1
      dulwich/server.py

+ 3 - 1
dulwich/porcelain.py

@@ -101,6 +101,7 @@ from dulwich.protocol import (
     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')

+ 3 - 2
dulwich/refs.py

@@ -44,6 +44,7 @@ from dulwich.file import (
 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 @@ class InfoRefsContainer(RefsContainer):
         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/')

+ 3 - 1
dulwich/server.py

@@ -106,6 +106,7 @@ from dulwich.protocol import (
     extract_want_line_capabilities,
     )
 from dulwich.refs import (
+    ANNOTATED_TAG_SUFFIX,
     write_info_refs,
     )
 from dulwich.repo import (
@@ -537,7 +538,8 @@ class ProtocolGraphWalker(object):
                 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)