Resolve within working_dir context manager

This commit is contained in:
Ines Montani 2020-06-30 13:29:45 +02:00
parent 72175b5c60
commit 8e20505970
2 changed files with 5 additions and 4 deletions

View File

@ -273,7 +273,7 @@ def project_init(
silent (bool): Don't print any output (via DVC). silent (bool): Don't print any output (via DVC).
analytics (bool): Opt-in to DVC analytics (defaults to False). analytics (bool): Opt-in to DVC analytics (defaults to False).
""" """
with working_dir(project_dir.resolve()) as cwd: with working_dir(project_dir) as cwd:
if git: if git:
run_command(["git", "init"]) run_command(["git", "init"])
init_cmd = ["dvc", "init"] init_cmd = ["dvc", "init"]

View File

@ -467,11 +467,12 @@ def working_dir(path: Union[str, Path]) -> None:
directory, to prevent mismatches with relative paths. directory, to prevent mismatches with relative paths.
""" """
prev_cwd = Path.cwd() prev_cwd = Path.cwd()
os.chdir(str(path)) current = Path(path).resolve()
os.chdir(str(current))
try: try:
yield Path(path).resolve() yield current
finally: finally:
os.chdir(prev_cwd) os.chdir(str(prev_cwd))
@contextmanager @contextmanager