Merge pull request #2485 from pared/2477

move: use relpath to find target path
This commit is contained in:
Ruslan Kuprieiev
2019-09-10 16:23:27 +03:00
committed by GitHub
2 changed files with 13 additions and 3 deletions
+3 -3
View File
@@ -59,9 +59,9 @@ def move(self, from_path, to_path):
os.path.join(os.curdir, os.path.dirname(to_path))
)
to_out = Output.loads_from(
stage, [os.path.basename(to_path)], out.use_cache, out.metric
)[0]
to_path = os.path.relpath(to_path, stage.wdir)
to_out = Output.loads_from(stage, [to_path], out.use_cache, out.metric)[0]
with self.state:
out.move(to_out)
+10
View File
@@ -200,3 +200,13 @@ def test_move_should_save_stage_info(dvc_repo, repo_dir):
dvc_repo.move(repo_dir.DATA_DIR, "new_name")
assert dvc_repo.status() == {}
def test_should_move_to_dir_on_non_default_stage_file(dvc_repo, repo_dir):
stage_file_name = "stage.dvc"
dvc_repo.add(repo_dir.FOO, fname=stage_file_name)
dvc_repo.move(repo_dir.FOO, repo_dir.DATA_DIR)
assert os.path.exists(os.path.join(repo_dir.DATA_DIR, repo_dir.FOO))