Example #1
0
    def test_treeitem_new(self):
        g = Git(GitOpt(), cwd=superp)

        tree = g.tree_of('master')
        lines = g.tree_items(tree, with_size=True)
        itm = g.treeitem_parse(lines[0])
        obj = itm['object']

        got = g.treeitem_new("foo", obj)
        self.assertEqual(
            '100644 blob 15d2fff1101916d7212371fea0f3a82bda750f6c\tfoo', got)

        got = g.treeitem_new("foo", obj, mode='100755')
        self.assertEqual(
            '100755 blob 15d2fff1101916d7212371fea0f3a82bda750f6c\tfoo', got)
Example #2
0
    def test_treeitem_parse(self):
        g = Git(GitOpt(), cwd=superp)

        tree = g.tree_of('master')
        lines = g.tree_items(tree, with_size=True)

        got = g.treeitem_parse(lines[0])
        self.assertEqual(
            {
                'fn': '.gift',
                'mode': '100644',
                'object': '15d2fff1101916d7212371fea0f3a82bda750f6c',
                'type': 'blob',
                'size': '163',
            }, got)
Example #3
0
    def test_tree_new_replace(self):
        g = Git(GitOpt(), cwd=superp)

        tree = g.tree_of('master')
        lines = g.tree_items(tree)

        itm = g.treeitem_parse(lines[0])
        obj = itm['object']

        treeish = g.tree_new_replace(lines, 'foo', obj, mode='100755')
        got = g.tree_items(treeish)

        self.assertEqual([
            '100644 blob 15d2fff1101916d7212371fea0f3a82bda750f6c\t.gift',
            '100755 blob 15d2fff1101916d7212371fea0f3a82bda750f6c\tfoo',
            '100644 blob a668431ae444a5b68953dc61b4b3c30e066535a2\timsuperman',
        ], got)