update: forbid updating repo-imports with --to-remote (#5475)

This commit is contained in:
Batuhan Taskaya
2021-02-22 11:55:00 +02:00
committed by GitHub
parent cccead3441
commit e1a193f00b
2 changed files with 16 additions and 0 deletions
+7
View File
@@ -1,9 +1,16 @@
import logging
from dvc.exceptions import InvalidArgumentError
logger = logging.getLogger(__name__)
def _update_import_on_remote(stage, remote, jobs):
if stage.is_repo_import:
raise InvalidArgumentError(
"Can't update a repo import with --to-remote"
)
url = stage.deps[0].path_info.url
stage.outs[0].hash_info = stage.repo.cloud.transfer(
url, jobs=jobs, remote=remote, command="update"
+9
View File
@@ -3,6 +3,7 @@ import os
import pytest
from dvc.dvcfile import Dvcfile
from dvc.exceptions import InvalidArgumentError
from tests.unit.fs.test_repo import make_subrepo
@@ -317,6 +318,14 @@ def test_update_from_subrepos(tmp_dir, dvc, erepo_dir, is_dvc):
}
def test_update_import_to_remote(tmp_dir, dvc, erepo_dir, local_remote):
erepo_dir.scm_gen({"foo": "foo"}, commit="add foo")
stage = dvc.imp(os.fspath(erepo_dir), "foo")
erepo_dir.scm_gen({"foo": "bar"}, commit="update foo")
with pytest.raises(InvalidArgumentError):
dvc.update(stage.path, to_remote=True)
@pytest.mark.parametrize(
"workspace",
[