Esempio n. 1
0
    def test0702_checkout_branch(self):
        local = os.path.join(LOCAL_DIRS, 'local')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        gitcmd.checkout(local, 'test_branch', True)
        gitcmd.branch(local)
        gitcmd.checkout(local, 'master')
        ret, out, err = gitcmd.branch(local)
        self.assertEqual(ret, 0)
        self.assertEqual("* master\n  test_branch", out)
Esempio n. 2
0
    def test0800_current_branch(self):
        local = os.path.join(LOCAL_DIRS, 'local')
        test_file = os.path.join(local, 'test')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        ret, out, err = gitcmd.current_branch(local)
        self.assertEqual(ret, 0)
        self.assertEqual(out, "master\n")
        gitcmd.checkout(local, branch="test_branch", new=True)
        ret, out, err = gitcmd.current_branch(local)
        self.assertEqual(ret, 0)
        self.assertEqual(out, "test_branch\n")
Esempio n. 3
0
    def test0703_checkout_nonexistent_branch(self):
        local = os.path.join(LOCAL_DIRS, 'local')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        ret, out, err = gitcmd.checkout(local, 'test_branch')
        self.assertEqual(ret, 1)
        self.assertIn(
            "pathspec 'test_branch' did not match any file(s) known to git",
            err)
Esempio n. 4
0
    def test0701_checkout_new_branch(self):
        local = os.path.join(LOCAL_DIRS, 'local')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        ret, out, err = gitcmd.checkout(local, 'test_branch', True)
        self.assertEqual(ret, 0)
        self.assertIn("Switched to a new branch 'test_branch'", err)
        ret, out, err = gitcmd.branch(local)
        self.assertEqual("  master\n* test_branch", out)
Esempio n. 5
0
    def test0700_checkout(self):
        local = os.path.join(LOCAL_DIRS, 'local')

        gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local')
        with open(os.path.join(local, 'file.txt'), 'w+') as f:
            print("test", file=f)
        ret, out, err = gitcmd.status(local)
        self.assertEqual(ret, 0)
        self.assertIn("Changes not staged for commit", out)
        ret, out, err = gitcmd.checkout(os.path.join(local, 'file.txt'))
        self.assertEqual(ret, 0)
        ret, out, err = gitcmd.status(local)
        self.assertIn("working tree clean", out)
Esempio n. 6
0
 def test0704_checkout_exception(self):
     with self.assertRaises(gitcmd.NotInRepositoryError):
         gitcmd.checkout('/tmp')