示例#1
0
 def setUp(self):
     super(ProtocolGraphWalkerEmptyTestCase, self).setUp()
     self._repo = MemoryRepo.init_bare([], {})
     backend = DictBackend({b'/': self._repo})
     self._walker = _ProtocolGraphWalker(
         TestUploadPackHandler(backend, [b'/', b'host=lolcats'],
                               TestProto()), self._repo.object_store,
         self._repo.get_peeled, self._repo.refs.get_symrefs)
示例#2
0
def _test_backend(objects, refs=None, named_files=None):
    if not refs:
        refs = {}
    if not named_files:
        named_files = {}
    repo = MemoryRepo.init_bare(objects, refs)
    for path, contents in named_files.items():
        repo._put_named_file(path, contents)
    return DictBackend({'/': repo})
    def test_commit_config_identity_in_memoryrepo(self):
        # commit falls back to the users' identity if it wasn't specified
        r = MemoryRepo.init_bare([], {})
        c = r.get_config()
        c.set((b"user", ), b"name", b"Jelmer")
        c.set((b"user", ), b"email", b"*****@*****.**")

        commit_sha = r.do_commit(b'message', tree=objects.Tree().id)
        self.assertEqual(b"Jelmer <*****@*****.**>", r[commit_sha].author)
        self.assertEqual(b"Jelmer <*****@*****.**>",
                         r[commit_sha].committer)
示例#4
0
 def test_receive_pack(self):
     commit = make_commit(id=ONE, parents=[], commit_time=111)
     self.backend.repos[b"/"] = MemoryRepo.init_bare(
         [commit], {b"refs/heads/master": commit.id})
     outf = BytesIO()
     exitcode = self.serve_command(ReceivePackHandler, [b"/"],
                                   BytesIO(b"0000"), outf)
     outlines = outf.getvalue().splitlines()
     self.assertEqual(2, len(outlines))
     self.assertEqual(
         b"1111111111111111111111111111111111111111 refs/heads/master",
         outlines[0][4:].split(b"\x00")[0])
     self.assertEqual(b"0000", outlines[-1])
     self.assertEqual(0, exitcode)
示例#5
0
 def setUp(self):
     super(ProtocolGraphWalkerTestCase, self).setUp()
     # Create the following commit tree:
     #   3---5
     #  /
     # 1---2---4
     commits = [
         make_commit(id=ONE, parents=[], commit_time=111),
         make_commit(id=TWO, parents=[ONE], commit_time=222),
         make_commit(id=THREE, parents=[ONE], commit_time=333),
         make_commit(id=FOUR, parents=[TWO], commit_time=444),
         make_commit(id=FIVE, parents=[THREE], commit_time=555),
     ]
     self._repo = MemoryRepo.init_bare(commits, {})
     backend = DictBackend({b'/': self._repo})
     self._walker = _ProtocolGraphWalker(
         TestUploadPackHandler(backend, [b'/', b'host=lolcats'],
                               TestProto()), self._repo.object_store,
         self._repo.get_peeled, self._repo.refs.get_symrefs)
示例#6
0
 def setUp(self):
     super(ReceivePackHandlerTestCase, self).setUp()
     self._repo = MemoryRepo.init_bare([], {})
     backend = DictBackend({b'/': self._repo})
     self._handler = ReceivePackHandler(backend, [b'/', b'host=lolcathost'],
                                        TestProto())
示例#7
0
    def test_bad_repo_path(self):
        repo = MemoryRepo.init_bare([], {})
        backend = DictBackend({b'/': repo})

        self.assertRaises(NotGitRepository,
                          lambda: backend.open_repository('/ups'))
示例#8
0
 def test_nonexistant(self):
     repo = MemoryRepo.init_bare([], {})
     backend = DictBackend({b'/': repo})
     self.assertRaises(NotGitRepository, backend.open_repository,
                       "/does/not/exist/unless/foo")
 def test_create_memory(self):
     repo = MemoryRepo.init_bare([], {})
     self._check_repo_contents(repo, True)
 def test_set_description(self):
     r = MemoryRepo.init_bare([], {})
     description = b"Some description"
     r.set_description(description)
     self.assertEqual(description, r.get_description())