fix(data status): handle missing .dir file from the cache on not_in_remote checks (#10822)

This commit is contained in:
skshetry
2025-07-31 07:57:15 +00:00
committed by GitHub
parent fade6c5991
commit ca73078b80
3 changed files with 62 additions and 3 deletions
+46
View File
@@ -918,3 +918,49 @@ def test_compat_legacy_new_cache_types(M, tmp_dir, dvc, scm):
"committed": {"added": M.unordered("foo", "bar")},
"git": M.dict(),
}
def test_missing_cache_remote_check(M, tmp_dir, dvc, scm, local_remote):
tmp_dir.dvc_gen({"dir": {"foo": "foo", "bar": "bar"}})
tmp_dir.dvc_gen("foobar", "foobar")
remove(dvc.cache.repo.path)
assert dvc.data_status(untracked_files="all", not_in_remote=True) == {
**EMPTY_STATUS,
"untracked": M.unordered("foobar.dvc", "dir.dvc", ".gitignore"),
"committed": {"added": M.unordered("foobar", join("dir", ""))},
"not_in_cache": M.unordered("foobar", join("dir", "")),
"git": M.dict(),
"not_in_remote": M.unordered("foobar", join("dir", "")),
}
assert dvc.data_status(
granular=True, untracked_files="all", not_in_remote=True
) == {
**EMPTY_STATUS,
"untracked": M.unordered("foobar.dvc", "dir.dvc", ".gitignore"),
"committed": {"added": M.unordered("foobar", join("dir", ""))},
"uncommitted": {"unknown": M.unordered(join("dir", "foo"), join("dir", "bar"))},
"not_in_cache": M.unordered("foobar", join("dir", "")),
"git": M.dict(),
"not_in_remote": M.unordered("foobar", join("dir", "")),
}
assert dvc.data_status(["dir"], untracked_files="all", not_in_remote=True) == {
**EMPTY_STATUS,
"committed": {"added": [join("dir", "")]},
"not_in_cache": [join("dir", "")],
"git": M.dict(),
"not_in_remote": [join("dir", "")],
}
assert dvc.data_status(
["dir"], untracked_files="all", not_in_remote=True, granular=True
) == {
**EMPTY_STATUS,
"committed": {"added": [join("dir", "")]},
"uncommitted": {"unknown": M.unordered(join("dir", "foo"), join("dir", "bar"))},
"not_in_cache": [join("dir", "")],
"git": M.dict(),
"not_in_remote": [join("dir", "")],
}