Beispiel #1
0
    def _do_test_parse_tree(self, parse_tree):
        dir = os.path.join(os.path.dirname(__file__), 'data', 'trees')
        o = Tree.from_path(sha_to_filename(dir, tree_sha))
        self.assertEqual([(b'a', 0o100644, a_sha), (b'b', 0o100644, b_sha)],
                          list(parse_tree(o.as_raw_string())))
        # test a broken tree that has a leading 0 on the file mode
        broken_tree = b'0100644 foo\0' + bytes(a_sha)

        def eval_parse_tree(*args, **kwargs):
            return list(parse_tree(*args, **kwargs))

        self.assertEqual([(b'foo', 0o100644, a_sha)],
                          eval_parse_tree(broken_tree))
        self.assertRaises(ObjectFormatException,
                          eval_parse_tree, broken_tree, strict=True)
Beispiel #2
0
 def _get_shafile_path(self, sha):
     # Check from object dir
     return sha_to_filename(self.path, sha)
Beispiel #3
0
 def get_sha_file(self, cls, base, sha):
     dir = os.path.join(os.path.dirname(__file__), 'data', base)
     return cls.from_path(sha_to_filename(dir, sha))