def test_head_branch(self): # branch_test_git_p is a git-dir with one commit:: # * 1d5ae3d (HEAD, origin/master, master) A a # write a ".git" file to specify the git-dir for the containing # git-work-tree. fwrite(branch_test_worktree_p, ".git", "gitdir: ../branch_test_git") g = Git(GitOpt(), cwd=branch_test_worktree_p) got = g.head_branch() self.assertEqual('master', got) # checkout to a commit pointing to no branch # It should return None g.checkout('origin/master') got = g.head_branch() self.assertIsNone(got) g.checkout('master')
def test_checkout(self): g = Git(GitOpt(), cwd=superp) g.checkout('master') self._fcontent("superman\n", superp, "imsuperman") self.assertRaises(CalledProcessError, g.checkout, "foo")
def test_init(self): g = Git(GitOpt(), gitdir=supergitp, working_dir=superp) g.checkout('master') self._fcontent("superman\n", superp, "imsuperman") self.assertRaises(CalledProcessError, g.checkout, "foo")