Ejemplo n.º 1
0
    def test_send_pack_without_changes(self):
        local = open_repo('a.git')
        self.addCleanup(tear_down_repo, local)

        target = open_repo('a.git')
        self.addCleanup(tear_down_repo, target)

        self.send_and_verify(b"master", local, target)
Ejemplo n.º 2
0
    def test_get_refs(self):
        local = open_repo('refs.git')
        self.addCleanup(tear_down_repo, local)

        client = LocalGitClient()
        refs = client.get_refs(local.path)
        self.assertDictEqual(local.refs.as_dict(), refs)
Ejemplo n.º 3
0
 def test_fetch_pack_none(self):
     c = LocalGitClient()
     s = open_repo('a.git')
     self.addCleanup(tear_down_repo, s)
     out = BytesIO()
     walker = MemoryRepo().get_graph_walker()
     ret = c.fetch_pack(
         s.path,
         lambda heads: [b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"],
         graph_walker=walker,
         pack_data=out.write)
     self.assertEqual({b'HEAD': b'refs/heads/master'}, ret.symrefs)
     self.assertEqual(
         {
             b'HEAD':
             b'a90fa2d900a17e99b433217e988c4eb4a2e9a097',
             b'refs/heads/master':
             b'a90fa2d900a17e99b433217e988c4eb4a2e9a097',
             b'refs/tags/mytag':
             b'28237f4dc30d0d462658d6b937b08a0f0b6ef55a',
             b'refs/tags/mytag-packed':
             b'b0931cadc54336e78a1d980420e3268903b57a50'
         }, ret.refs)
     # Hardcoding is not ideal, but we'll fix that some other day..
     self.assertTrue(
         out.getvalue().startswith(b'PACK\x00\x00\x00\x02\x00\x00\x00\x07'))
Ejemplo n.º 4
0
 def test_fetch_empty(self):
     c = LocalGitClient()
     s = open_repo('a.git')
     self.addCleanup(tear_down_repo, s)
     out = BytesIO()
     walker = {}
     ret = c.fetch_pack(s.path,
                        lambda heads: [],
                        graph_walker=walker,
                        pack_data=out.write)
     self.assertEqual(
         {
             b'HEAD':
             b'a90fa2d900a17e99b433217e988c4eb4a2e9a097',
             b'refs/heads/master':
             b'a90fa2d900a17e99b433217e988c4eb4a2e9a097',
             b'refs/tags/mytag':
             b'28237f4dc30d0d462658d6b937b08a0f0b6ef55a',
             b'refs/tags/mytag-packed':
             b'b0931cadc54336e78a1d980420e3268903b57a50'
         }, ret.refs)
     self.assertEqual({b'HEAD': b'refs/heads/master'}, ret.symrefs)
     self.assertEqual(
         b"PACK\x00\x00\x00\x02\x00\x00\x00\x00\x02\x9d\x08"
         b"\x82;\xd8\xa8\xea\xb5\x10\xadj\xc7\\\x82<\xfd>\xd3\x1e",
         out.getvalue())
Ejemplo n.º 5
0
    def test_send_pack_with_changes(self):
        local = open_repo('a.git')
        self.addCleanup(tear_down_repo, local)

        target_path = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, target_path)
        with Repo.init_bare(target_path) as target:
            self.send_and_verify(b"master", local, target)
Ejemplo n.º 6
0
 def setUp(self):
     TestCase.setUp(self)
     self._repo = open_repo('refs.git')
     self.addCleanup(tear_down_repo, self._repo)
     self._refs = self._repo.refs
 def open_repo(self, name):
     temp_dir = self.mkdtemp()
     repo = open_repo(name, temp_dir)
     self.addCleanup(tear_down_repo, repo)
     return repo
Ejemplo n.º 8
0
 def test_fetch_into_empty(self):
     c = LocalGitClient()
     t = MemoryRepo()
     s = open_repo('a.git')
     self.addCleanup(tear_down_repo, s)
     self.assertEqual(s.get_refs(), c.fetch(s.path, t).refs)