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

        # parent of master
        parent = g.rev_of('master~')

        g.branch_set('master', 'master~')

        self.assertEqual(parent, g.rev_of('master'))
Example #2
0
    def test_rev_of(self):
        g = Git(GitOpt(), cwd=superp)
        t = g.rev_of("abc")
        self.assertIsNone(t)

        t = g.rev_of("master")
        self.assertEqual("c3954c897dfe40a5b99b7145820eeb227210265c", t)

        t = g.rev_of("refs/heads/master")
        self.assertEqual("c3954c897dfe40a5b99b7145820eeb227210265c", t)

        t = g.rev_of("c3954c897dfe40a5b99b7145820eeb227210265c")
        self.assertEqual("c3954c897dfe40a5b99b7145820eeb227210265c", t)
Example #3
0
    def test_tree_commit(self):
        g = Git(GitOpt(), cwd=superp)

        # get the content of parent of master
        # Thus the changes looks like reverting the changes in master.
        tree = g.tree_of('master~')
        dd("tree:", tree)

        commit = g.tree_commit(tree, "test_tree_commit", [g.rev_of('master')])
        dd("commit:", commit)

        got = cmdout(origit,
                     'log',
                     commit,
                     '-n2',
                     '--stat',
                     '--format="%s"',
                     cwd=superp)
        dd(got)

        self.assertEqual([
            '"test_tree_commit"', '', ' imsuperman | 1 -',
            ' 1 file changed, 1 deletion(-)', '"add super"', '',
            ' imsuperman | 1 +', ' 1 file changed, 1 insertion(+)'
        ], got)