Pārlūkot izejas kodu

a Tag object can refer to any other object, not just a Commit object

Ali Sabil 16 gadi atpakaļ
vecāks
revīzija
32f5525c5b
2 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 2 1
      dulwich/objects.py
  2. 1 1
      dulwich/tests/test_objects.py

+ 2 - 1
dulwich/objects.py

@@ -247,8 +247,9 @@ class Tag(ShaFile):
         self._object_type += text[count]
         count += 1
     count += 1
-    assert self._object_type in (COMMIT_ID,), "Invalid tag object, " \
+    assert self._object_type in (COMMIT_ID, BLOB_ID, TREE_ID, TAG_ID), "Invalid tag object, " \
         "unexpected object type %s" % self._object_type
+    self._object_type = type_map[self._object_type]
 
     assert text[count:].startswith(TAG_ID), "Invalid tag object, " \
         "object type must be followed by %s" % (TAG_ID)

+ 1 - 1
dulwich/tests/test_objects.py

@@ -86,7 +86,7 @@ class BlobReadTests(unittest.TestCase):
 
   def test_read_tag_from_file(self):
     t = self.get_tag(tag_sha)
-    self.assertEqual(t.object, ('commit', '51b668fd5bf7061b7d6fa525f88803e6cfadaa51'))
+    self.assertEqual(t.object, (Commit, '51b668fd5bf7061b7d6fa525f88803e6cfadaa51'))
     self.assertEqual(t.name,'signed')
     self.assertEqual(t.tagger,'Ali Sabil <ali.sabil@gmail.com>')
     self.assertEqual(t.tag_time, 1231203091)