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)
def test0600_branch(self): local = os.path.join(LOCAL_DIRS, 'local') test_file = os.path.join(local, 'test') gitcmd.clone(LOCAL_DIRS, HOST_DIR, to='local') open(test_file, 'w+').close() gitcmd.add(test_file) gitcmd.commit(test_file, 'test') gitcmd.push(local, HOST_DIR) ret, out, err = gitcmd.branch(local) self.assertEqual(ret, 0) self.assertEqual(out, "* master") ret, out, err = gitcmd.branch(test_file) self.assertEqual(ret, 0) self.assertEqual(out, "* master")
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)
def test0601_branch_exception(self): with self.assertRaises(gitcmd.NotInRepositoryError): gitcmd.branch('/tmp')