data status: remove --withdirs, show unknowns in CLI (#8189)

* data status: remove --withdirs, show unknowns in CLI

* data status: only consider unknown from newer object during diff
This commit is contained in:
skshetry
2022-08-30 12:11:02 +05:45
committed by GitHub
parent e5eec59cb8
commit bfad82a2e3
4 changed files with 45 additions and 48 deletions
+40 -18
View File
@@ -29,6 +29,7 @@ def test_git_to_dvc_path_wdir_transformation(tmp_dir, scm, path):
with subdir.chdir():
subdir.gen(struct)
_, _, untracked = scm.status(untracked_files="all")
# make order independent of the platforms for easier test assertions
untracked = sorted(untracked, reverse=True)
assert _transform_git_paths_to_dvc(dvc, untracked) == [
"file",
@@ -83,11 +84,12 @@ def test_directory(M, tmp_dir, dvc, scm):
"added": M.unordered(
join("dir", "bar"),
join("dir", "foobar"),
)
),
"modified": [join("dir", "")],
},
"uncommitted": {
"added": [join("dir", "baz")],
"modified": [join("dir", "bar")],
"modified": M.unordered(join("dir", ""), join("dir", "bar")),
"deleted": [join("dir", "foobar")],
},
"git": M.dict(),
@@ -124,17 +126,7 @@ def test_unchanged(M, tmp_dir, dvc, scm):
assert dvc.data_status(granular=True) == {
**EMPTY_STATUS,
"git": M.dict(),
"unchanged": M.unordered("bar", join("dir", "foo")),
}
def test_withdirs(M, tmp_dir, dvc, scm):
tmp_dir.dvc_gen({"dir": {"foo": "foo"}}, commit="add dir")
tmp_dir.dvc_gen("bar", "bar", commit="add foo")
assert dvc.data_status(granular=True, with_dirs=True) == {
**EMPTY_STATUS,
"git": M.dict(),
"unchanged": M.unordered("bar", join("dir", "foo"), join("dir", "")),
"unchanged": M.unordered("bar", join("dir", ""), join("dir", "foo")),
}
@@ -171,7 +163,9 @@ def test_subdir(M, tmp_dir, scm):
assert dvc.data_status(granular=True, untracked_files="all") == {
**EMPTY_STATUS,
"git": M.dict(),
"unchanged": M.unordered("bar", join("dir", "foo")),
"unchanged": M.unordered(
"bar", join("dir", ""), join("dir", "foo")
),
"untracked": ["untracked"],
}
@@ -305,7 +299,9 @@ def test_partial_missing_cache(M, tmp_dir, dvc, scm):
assert dvc.data_status(granular=True) == {
**EMPTY_STATUS,
"committed": {
"added": M.unordered(join("dir", "foo"), join("dir", "bar"))
"added": M.unordered(
join("dir", ""), join("dir", "foo"), join("dir", "bar")
)
},
"not_in_cache": [join("dir", "foo")],
"git": M.dict(),
@@ -336,6 +332,30 @@ def test_missing_dir_object_from_head(M, tmp_dir, dvc, scm):
}
def test_missing_dir_object_from_index(M, tmp_dir, dvc, scm):
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}}, commit="add dir")
remove("dir")
(stage,) = tmp_dir.dvc_gen({"dir": {"foobar": "foobar"}})
odb = dvc.odb.repo
odb.fs.rm(odb.oid_to_path(stage.outs[0].hash_info.value))
assert dvc.data_status() == {
**EMPTY_STATUS,
"committed": {"modified": [join("dir", "")]},
"not_in_cache": [join("dir", "")],
"git": M.dict(),
}
assert dvc.data_status(granular=True) == {
**EMPTY_STATUS,
"committed": {
"modified": [join("dir", "")],
},
"uncommitted": {"unknown": [join("dir", "foobar")]},
"not_in_cache": [join("dir", "")],
"git": M.dict(),
}
def test_root_from_dir_to_file(M, tmp_dir, dvc, scm):
tmp_dir.dvc_gen({"data": {"foo": "foo", "bar": "bar"}})
remove("data")
@@ -344,13 +364,15 @@ def test_root_from_dir_to_file(M, tmp_dir, dvc, scm):
assert dvc.data_status() == {
**EMPTY_STATUS,
"committed": {"added": [join("data", "")]},
"uncommitted": {"modified": [join("data")]},
"uncommitted": {"modified": ["data"]},
"git": M.dict(),
}
assert dvc.data_status(granular=True) == {
**EMPTY_STATUS,
"committed": {
"added": M.unordered(join("data", "foo"), join("data", "bar"))
"added": M.unordered(
join("data", ""), join("data", "foo"), join("data", "bar")
)
},
"uncommitted": {
"deleted": M.unordered(join("data", "foo"), join("data", "bar")),
@@ -373,7 +395,7 @@ def test_root_from_file_to_dir(M, tmp_dir, dvc, scm):
}
assert dvc.data_status(granular=True) == {
**EMPTY_STATUS,
"committed": {"added": [join("data")]},
"committed": {"added": ["data"]},
"uncommitted": {
"modified": [join("data", "")],
"added": M.unordered(join("data", "foo"), join("data", "bar")),