mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 07:18:27 +01:00
out: str: don't try to relpath paths outside of the repo
This is not very useful overall, but also results in a ValueError from relpath on windows if your repo and output are on different drives.
This commit is contained in:
@@ -488,6 +488,9 @@ class Output:
|
||||
):
|
||||
return str(self.def_path)
|
||||
|
||||
if not self.fs.path.isin(self.fs_path, self.repo.root_dir):
|
||||
return self.fs_path
|
||||
|
||||
cur_dir = self.fs.path.getcwd()
|
||||
if self.fs.path.isin(cur_dir, self.repo.root_dir):
|
||||
return self.fs.path.relpath(self.fs_path, cur_dir)
|
||||
|
||||
@@ -2,7 +2,6 @@ import os
|
||||
|
||||
from dvc.output import Output
|
||||
from dvc.stage import Stage
|
||||
from dvc.utils import relpath
|
||||
from dvc_data.hashfile.hash_info import HashInfo
|
||||
from dvc_data.hashfile.meta import Meta
|
||||
|
||||
@@ -11,7 +10,7 @@ def test_str_workdir_outside_repo(tmp_dir, erepo_dir):
|
||||
stage = Stage(erepo_dir.dvc)
|
||||
output = Output(stage, "path", cache=False)
|
||||
|
||||
assert relpath("path", erepo_dir.dvc.root_dir) == str(output)
|
||||
assert os.path.abspath("path") == str(output)
|
||||
|
||||
|
||||
def test_str_workdir_inside_repo(dvc):
|
||||
|
||||
Reference in New Issue
Block a user