a Tag object can refer to any other object, not just a Commit object
authorAli Sabil <ali.sabil@gmail.com>
Tue, 6 Jan 2009 09:23:24 +0000 (09:23 +0000)
committerAli Sabil <ali.sabil@gmail.com>
Tue, 6 Jan 2009 09:23:24 +0000 (09:23 +0000)
dulwich/objects.py
dulwich/tests/test_objects.py

index 61bf07cdf3446fc0bf73a1528684e71e039369df..e86b70ce2dcec4474af6fdf06cf0709a051aeee5 100644 (file)
@@ -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)
index 9ea30f1ab5ac84d0adde5c2622c37169166974cc..d878ffd5a7c3d6697099fb677193c37a8b6145d4 100644 (file)
@@ -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)