From a16dc58ae3a4913d732f9c7a5f065af1a3a780d1 Mon Sep 17 00:00:00 2001 From: pawel Date: Tue, 10 Sep 2019 14:03:55 +0200 Subject: [PATCH] move: use relpath to find target path --- dvc/repo/move.py | 6 +++--- tests/func/test_move.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dvc/repo/move.py b/dvc/repo/move.py index 6cd8b915c4..84c506ca74 100644 --- a/dvc/repo/move.py +++ b/dvc/repo/move.py @@ -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) diff --git a/tests/func/test_move.py b/tests/func/test_move.py index 3004c7b291..83484e542d 100644 --- a/tests/func/test_move.py +++ b/tests/func/test_move.py @@ -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))