resolve_rev: raise DvcException on empty repo.

This commit is contained in:
David de la Iglesia Castro
2022-08-29 01:50:14 +03:00
committed by Ruslan Kuprieiev
parent 2cef130191
commit 9e2ebe9fcc
3 changed files with 11 additions and 4 deletions
+1 -3
View File
@@ -279,9 +279,7 @@ def _transform_git_paths_to_dvc(repo: "Repo", files: Iterable[str]):
def status(repo: "Repo", untracked_files: str = "no", **kwargs: Any) -> Status:
from scmrepo.exceptions import SCMError
from dvc.scm import NoSCMError
from dvc.scm import NoSCMError, SCMError
head = kwargs.pop("head", "HEAD")
uncommitted_diff = _diff_index_to_wtree(repo, **kwargs)
+1 -1
View File
@@ -160,7 +160,7 @@ def resolve_rev(scm: "Git", rev: str) -> str:
except InternalRevError as exc:
# `scm` will only resolve git branch and tag names,
# if rev is not a sha it may be an abbreviated experiment name
if not rev.startswith("refs/"):
if not (rev == "HEAD" or rev.startswith("refs/")):
from dvc.repo.experiments.utils import (
AmbiguousExpRefInfo,
resolve_name,
+9
View File
@@ -0,0 +1,9 @@
import pytest
from dvc.exceptions import DvcException
from dvc.scm import resolve_rev
def test_resolve_rev_empty_git_repo(scm):
with pytest.raises(DvcException):
resolve_rev(scm, "HEAD")