def test_tag(self): c1, c2 = self.make_linear_commits(2) tag = make_tag(c2, name=b'tag') self._store.add_object(tag) self.assertEqual((set([c1.id]), set([c2.id])), _find_shallow(self._store, [tag.id], 2))
def setUpClass(cls): cls.projdir = tempfile.mkdtemp() # temporary project directory cls.repo = Repo.init(cls.projdir) # test repo obj_store = cls.repo.object_store # test repo object store # commit 1 ('2017-01-19T01:06:43') cls.c1 = make_commit( id=cls.tag_test_data[cls.test_tags[0]][1], commit_time=cls.tag_test_data[cls.test_tags[0]][0], message=b'unannotated tag', author=cls.committer ) obj_store.add_object(cls.c1) # tag 1: unannotated cls.t1 = cls.test_tags[0] cls.repo[b'refs/tags/' + cls.t1] = cls.c1.id # add unannotated tag # commit 2 ('2017-01-19T01:11:54') cls.c2 = make_commit( id=cls.tag_test_data[cls.test_tags[1]][1], commit_time=cls.tag_test_data[cls.test_tags[1]][0], message=b'annotated tag', parents=[cls.c1.id], author=cls.committer ) obj_store.add_object(cls.c2) # tag 2: annotated ('2017-01-19T01:13:21') cls.t2 = make_tag( cls.c2, id=cls.tag_test_data[cls.test_tags[1]][2][1], name=cls.test_tags[1], tag_time=cls.tag_test_data[cls.test_tags[1]][2][0] ) obj_store.add_object(cls.t2) cls.repo[b'refs/heads/master'] = cls.c2.id cls.repo[b'refs/tags/' + cls.t2.name] = cls.t2.id # add annotated tag
def test_get_info_refs(self): self._environ['QUERY_STRING'] = '' blob1 = make_object(Blob, data=b'1') blob2 = make_object(Blob, data=b'2') blob3 = make_object(Blob, data=b'3') tag1 = make_tag(blob2, name=b'tag-tag') objects = [blob1, blob2, blob3, tag1] refs = { b'HEAD': b'000', b'refs/heads/master': blob1.id, b'refs/tags/tag-tag': tag1.id, b'refs/tags/blob-tag': blob3.id, } backend = _test_backend(objects, refs=refs) mat = re.search('.*', '//info/refs') self.assertEqual([blob1.id + b'\trefs/heads/master\n', blob3.id + b'\trefs/tags/blob-tag\n', tag1.id + b'\trefs/tags/tag-tag\n', blob2.id + b'\trefs/tags/tag-tag^{}\n'], list(get_info_refs(self._req, backend, mat))) self.assertEqual(HTTP_OK, self._status) self.assertContentTypeEquals('text/plain') self.assertFalse(self._req.cached)
def test_tag(self): c1, c2 = self.make_linear_commits(2) tag = make_tag(c2, name=b'tag') self._store.add_object(tag) self.assertEqual((set([c1.id]), set([c2.id])), _find_shallow(self._store, [tag.id], 1))
def test_get_info_refs(self): self._environ['QUERY_STRING'] = '' blob1 = make_object(Blob, data=b'1') blob2 = make_object(Blob, data=b'2') blob3 = make_object(Blob, data=b'3') tag1 = make_tag(blob2, name=b'tag-tag') objects = [blob1, blob2, blob3, tag1] refs = { b'HEAD': b'000', b'refs/heads/master': blob1.id, b'refs/tags/tag-tag': tag1.id, b'refs/tags/blob-tag': blob3.id, } backend = _test_backend(objects, refs=refs) mat = re.search('.*', '//info/refs') self.assertEqual([ blob1.id + b'\trefs/heads/master\n', blob3.id + b'\trefs/tags/blob-tag\n', tag1.id + b'\trefs/tags/tag-tag\n', blob2.id + b'\trefs/tags/tag-tag^{}\n' ], list(get_info_refs(self._req, backend, mat))) self.assertEqual(HTTP_OK, self._status) self.assertContentTypeEquals('text/plain') self.assertFalse(self._req.cached)
def test_get_info_refs(self): self._environ["QUERY_STRING"] = "" blob1 = make_object(Blob, data=b"1") blob2 = make_object(Blob, data=b"2") blob3 = make_object(Blob, data=b"3") tag1 = make_tag(blob2, name=b"tag-tag") objects = [blob1, blob2, blob3, tag1] refs = { b"HEAD": b"000", b"refs/heads/master": blob1.id, b"refs/tags/tag-tag": tag1.id, b"refs/tags/blob-tag": blob3.id, } backend = _test_backend(objects, refs=refs) mat = re.search(".*", "//info/refs") self.assertEqual( [ blob1.id + b"\trefs/heads/master\n", blob3.id + b"\trefs/tags/blob-tag\n", tag1.id + b"\trefs/tags/tag-tag\n", blob2.id + b"\trefs/tags/tag-tag^{}\n", ], list(get_info_refs(self._req, backend, mat)), ) self.assertEqual(HTTP_OK, self._status) self.assertContentTypeEquals("text/plain") self.assertFalse(self._req.cached)
def setUpClass(cls): cls.projdir = tempfile.mkdtemp() # temporary project directory cls.repo = Repo.init(cls.projdir) # test repo obj_store = cls.repo.object_store # test repo object store # commit 1 ('2017-01-19T01:06:43') cls.c1 = make_commit( id=cls.tag_test_data[cls.test_tags[0]][1], commit_time=cls.tag_test_data[cls.test_tags[0]][0], message=b'unannotated tag', author=cls.committer) obj_store.add_object(cls.c1) # tag 1: unannotated cls.t1 = cls.test_tags[0] cls.repo[b'refs/tags/' + cls.t1] = cls.c1.id # add unannotated tag # commit 2 ('2017-01-19T01:11:54') cls.c2 = make_commit( id=cls.tag_test_data[cls.test_tags[1]][1], commit_time=cls.tag_test_data[cls.test_tags[1]][0], message=b'annotated tag', parents=[cls.c1.id], author=cls.committer) obj_store.add_object(cls.c2) # tag 2: annotated ('2017-01-19T01:13:21') cls.t2 = make_tag(cls.c2, id=cls.tag_test_data[cls.test_tags[1]][2][1], name=cls.test_tags[1], tag_time=cls.tag_test_data[cls.test_tags[1]][2][0]) obj_store.add_object(cls.t2) cls.repo[b'refs/heads/master'] = cls.c2.id cls.repo[b'refs/tags/' + cls.t2.name] = cls.t2.id # add annotated tag
def setUp(self): super(MOFTagsTest, self).setUp() f1_1 = make_object(Blob, data=b'f1') commit_spec = [[1]] trees = {1: [(b'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 make_tag(self, name, obj): tag = make_tag(obj, name=name) self.store.add_object(tag) return tag
def test_tag(self): c1, c2, c3 = self.make_linear_commits(3) t2 = make_tag(target=c2) self.store.add_object(t2) self.assertWalkYields([c2, c1], [t2.id])