repo: use realpath to in _get_filepath when loading stages

This commit is contained in:
Daniele Trifirò
2022-10-03 15:29:01 +02:00
committed by daniele
parent a686dded15
commit 3adede8427
2 changed files with 19 additions and 3 deletions
+2 -3
View File
@@ -225,10 +225,9 @@ class StageLoad:
path, name = parse_target(target)
return self.load_one(path=path, name=name)
@staticmethod
def _get_filepath(path: str = None, name: str = None) -> str:
def _get_filepath(self, path: str = None, name: str = None) -> str:
if path:
return path
return self.repo.fs.path.realpath(path)
path = PIPELINE_FILE
logger.debug("Assuming '%s' to be a stage inside '%s'", name, path)
+17
View File
@@ -265,6 +265,23 @@ def test_collect_repo_ignored_dir_unignored_pattern(tmp_dir, dvc, scm):
assert dvc.stage.collect_repo() == [stage]
@pytest.mark.parametrize("with_deps", (False, True))
def test_collect_symlink(tmp_dir, dvc, with_deps):
tmp_dir.gen({"data": {"foo": "foo contents"}})
foo_path = os.path.join("data", "foo")
dvc.add(foo_path)
data_link = tmp_dir / "data_link"
data_link.symlink_to("data")
stage = list(
dvc.stage.collect(
target=str(data_link / "foo.dvc"), with_deps=with_deps
)
)[0]
assert stage.addressing == f"{foo_path}.dvc"
def test_stage_strings_representation(tmp_dir, dvc, run_copy):
tmp_dir.dvc_gen("foo", "foo")
stage1 = run_copy("foo", "bar", single_stage=True)