diff: improve RevError message

This commit is contained in:
Mr. Outis
2020-01-27 14:27:56 -06:00
parent a12d81fd0a
commit 3c6b52bb91
3 changed files with 9 additions and 10 deletions
+1 -4
View File
@@ -27,10 +27,7 @@ class CloneError(SCMError):
class RevError(SCMError):
def __init__(self, url, rev):
super().__init__(
"failed to access revision '{}' for repo '{}'".format(rev, url)
)
pass
class Base(object):
+7 -3
View File
@@ -94,7 +94,11 @@ class Git(Base):
try:
repo.checkout(rev)
except git.exc.GitCommandError as exc:
raise RevError(url, rev) from exc
raise RevError(
"failed to access revision '{}' for repo '{}'".format(
rev, url
)
) from exc
return repo
@@ -367,8 +371,8 @@ class Git(Base):
try:
return self.repo.git.rev_parse(rev)
except GitCommandError as exc:
raise RevError(url=self.root_dir, rev=rev) from exc
except GitCommandError:
raise RevError("unknown Git revision '{}'".format(rev))
def close(self):
self.repo.close()
+1 -3
View File
@@ -107,9 +107,7 @@ def test_refs(tmp_dir, scm, dvc):
],
}
with pytest.raises(
DvcException, match=r"failed to access revision 'missing'"
):
with pytest.raises(DvcException, match=r"unknown Git revision 'missing'"):
dvc.diff("missing")