Skip to content

Commit

Permalink
erepo: fix known sha handling (#3323)
Browse files Browse the repository at this point in the history
Closes #3280.
  • Loading branch information
Suor committed Feb 14, 2020
1 parent 51a5a4e commit 7df06b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dvc/external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 15 additions & 0 deletions tests/func/test_external_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7df06b2

Please sign in to comment.