def test_bad_format_missing_rev(self): """ If the format is correct but the revisions are missing. """ with self.assertRaises(GitRevListFormatError): parse_rev_range(self.gitrepodir, "..B") with self.assertRaises(GitRevListFormatError): parse_rev_range(self.gitrepodir, "A..")
def test_local_branch(self): """ A branch that is newly created can be referenced. """ self.gitrepo.create_head("feature-branch") self.assertIsRevRange(parse_rev_range(self.gitrepodir, "HEAD^1..feature-branch"))
def _diff_for(gitrepo, rev_range=None): """ Get a list of :py:class:`git.diff.Diff` objects for the repository. :param git.repo.base.Repo gitrepo: Git repository :param string rev_range: optional revision to use instead of the Git index """ if rev_range: commit_a, commit_b = parse_rev_range(gitrepo.working_dir, rev_range) return commit_a.diff(commit_b) else: # Assume we want a diff between what is staged and HEAD try: return gitrepo.head.commit.diff() except ValueError: return None
def test_out_of_range(self): """ A revision is out of range. """ with self.assertRaises(GitRevListMissing): parse_rev_range(self.gitrepodir, "HEAD~1000..HEAD")
def test_good_revs(self): """ The revisions to exist. """ self.assertIsRevRange(parse_rev_range(self.gitrepodir, "HEAD^1..HEAD"))
def test_bad_revs(self): """ If the format is good but the revisions do not exist. """ with self.assertRaises(GitRevListMissing): parse_rev_range(self.gitrepodir, "FOO..BAR")
def test_bad_format(self): """ If the revision range doesn't match the expected format. """ with self.assertRaises(GitRevListFormatError): parse_rev_range(self.gitrepodir, "A-B")