mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Our gitfs paths are currently tied to the local path in which the cloned repository resides in, which results in a lot of hacky assumptions throughout the code. This PR detaches gitfs from local paths completely, making dvc work with a proper fsspec gitfs implementation. Part of #7543
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import json
|
|
import os
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"stage_wdir, cwd, target",
|
|
[
|
|
(os.curdir, os.curdir, "foo"),
|
|
(os.curdir, os.curdir, "train"),
|
|
(os.curdir, os.curdir, "dvc.yaml:train"),
|
|
(os.curdir, "sub", os.path.join(os.pardir, "foo")),
|
|
(
|
|
os.curdir,
|
|
"sub",
|
|
os.path.join(os.pardir, "dvc.yaml:train"),
|
|
),
|
|
("sub", os.curdir, os.path.join("sub", "foo")),
|
|
("sub", os.curdir, os.path.join("sub", "dvc.yaml:train")),
|
|
("sub", "sub", "foo"),
|
|
("sub", "sub", "train"),
|
|
("sub", "sub", "dvc.yaml:train"),
|
|
("sub", "dir", os.path.join(os.pardir, "sub", "foo")),
|
|
(
|
|
"sub",
|
|
"dir",
|
|
os.path.join(os.pardir, "sub", "dvc.yaml:train"),
|
|
),
|
|
],
|
|
)
|
|
def test_from_gitfs_when_pwd_not_in_root(
|
|
tmp_dir, scm, dvc, stage_wdir, cwd, target
|
|
):
|
|
path = tmp_dir.joinpath(stage_wdir).resolve()
|
|
path.mkdir(parents=True, exist_ok=True)
|
|
wdir = tmp_dir.joinpath(cwd).resolve()
|
|
wdir.mkdir(parents=True, exist_ok=True)
|
|
|
|
(path / "dvc.yaml").write_text(
|
|
json.dumps(
|
|
{"stages": {"train": {"cmd": "echo foo > foo", "outs": ["foo"]}}}
|
|
)
|
|
)
|
|
path.gen({"foo": "foo"})
|
|
dvc.commit(None, force=True)
|
|
tmp_dir.scm_add(
|
|
[path / file for file in ("dvc.yaml", "dvc.lock", ".gitignore")],
|
|
commit="add files",
|
|
)
|
|
|
|
with wdir.chdir():
|
|
assert dvc.used_objs([target], revs=[scm.get_rev()])
|