|
@@ -25,6 +25,7 @@ from dulwich.objects import (
|
|
|
from dulwich.tests import TestCase
|
|
|
from dulwich.tests.utils import (
|
|
|
make_object,
|
|
|
+ make_tag,
|
|
|
build_commit_graph,
|
|
|
skipIfPY3,
|
|
|
)
|
|
@@ -194,3 +195,58 @@ class MOFMergeForkRepoTest(MissingObjectFinderTest):
|
|
|
self.cmt(7).id, self.cmt(6).id, self.cmt(4).id,
|
|
|
self.cmt(7).tree, self.cmt(6).tree, self.cmt(4).tree,
|
|
|
self.f1_4_id])
|
|
|
+
|
|
|
+
|
|
|
+class MOFTagsTest(MissingObjectFinderTest):
|
|
|
+ def setUp(self):
|
|
|
+ super(MOFTagsTest, self).setUp()
|
|
|
+ f1_1 = make_object(Blob, data='f1')
|
|
|
+ commit_spec = [[1]]
|
|
|
+ trees = {1: [('f1', f1_1)]}
|
|
|
+ self.commits = build_commit_graph(self.store, commit_spec, trees)
|
|
|
+
|
|
|
+ self._normal_tag = make_tag(self.cmt(1))
|
|
|
+ self.store.add_object(self._normal_tag)
|
|
|
+
|
|
|
+ self._tag_of_tag = make_tag(self._normal_tag)
|
|
|
+ self.store.add_object(self._tag_of_tag)
|
|
|
+
|
|
|
+ self._tag_of_tree = make_tag(self.store[self.cmt(1).tree])
|
|
|
+ self.store.add_object(self._tag_of_tree)
|
|
|
+
|
|
|
+ self._tag_of_blob = make_tag(f1_1)
|
|
|
+ self.store.add_object(self._tag_of_blob)
|
|
|
+
|
|
|
+ self._tag_of_tag_of_blob = make_tag(self._tag_of_blob)
|
|
|
+ self.store.add_object(self._tag_of_tag_of_blob)
|
|
|
+
|
|
|
+ self.f1_1_id = f1_1.id
|
|
|
+
|
|
|
+ def test_tagged_commit(self):
|
|
|
+ # The user already has the tagged commit, all they want is the tag,
|
|
|
+ # so send them only the tag object.
|
|
|
+ self.assertMissingMatch([self.cmt(1).id], [self._normal_tag.id],
|
|
|
+ [self._normal_tag.id])
|
|
|
+
|
|
|
+ # The remaining cases are unusual, but do happen in the wild.
|
|
|
+ def test_tagged_tag(self):
|
|
|
+ # User already has tagged tag, send only tag of tag
|
|
|
+ self.assertMissingMatch([self._normal_tag.id], [self._tag_of_tag.id],
|
|
|
+ [self._tag_of_tag.id])
|
|
|
+ # User needs both tags, but already has commit
|
|
|
+ self.assertMissingMatch([self.cmt(1).id], [self._tag_of_tag.id],
|
|
|
+ [self._normal_tag.id, self._tag_of_tag.id])
|
|
|
+
|
|
|
+ def test_tagged_tree(self):
|
|
|
+ self.assertMissingMatch(
|
|
|
+ [], [self._tag_of_tree.id],
|
|
|
+ [self._tag_of_tree.id, self.cmt(1).tree, self.f1_1_id])
|
|
|
+
|
|
|
+ def test_tagged_blob(self):
|
|
|
+ self.assertMissingMatch([], [self._tag_of_blob.id],
|
|
|
+ [self._tag_of_blob.id, self.f1_1_id])
|
|
|
+
|
|
|
+ def test_tagged_tagged_blob(self):
|
|
|
+ self.assertMissingMatch([], [self._tag_of_tag_of_blob.id],
|
|
|
+ [self._tag_of_tag_of_blob.id,
|
|
|
+ self._tag_of_blob.id, self.f1_1_id])
|