mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-17 07:18:26 +01:00
diff: improve RevError message
This commit is contained in:
+1
-4
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user