erepo: fix known sha handling (#3323)

Closes #3280.
This commit is contained in:
Alexander Schepanovski
2020-02-14 12:59:31 +02:00
committed by GitHub
parent 51a5a4ec3b
commit 7df06b278a
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -200,7 +200,7 @@ def _clone_default_branch(url, rev):
if clone_path:
git = Git(clone_path)
# Do not pull for known shas, branches and tags might move
if not Git.is_sha(rev) or not git.is_known(rev):
if not Git.is_sha(rev) or not git.has_rev(rev):
git.pull()
else:
clone_path = tempfile.mkdtemp("dvc-clone")
+15
View File
@@ -56,3 +56,18 @@ def test_cache_reused(erepo_dir, mocker):
with external_repo(url, "branch") as repo:
repo.fetch()
assert download_spy.mock.call_count == 1
def test_known_sha(erepo_dir):
url = "file://{}".format(erepo_dir)
with external_repo(url) as repo:
rev = repo.scm.get_rev()
prev_rev = repo.scm.resolve_rev("HEAD^")
# Hits cache
with external_repo(url, rev) as repo:
pass
# No clone, no pull, copies a repo, checks out the known sha
with external_repo(url, prev_rev) as repo:
pass