mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
fix(diff): show in "Not in cache" if dir entry is missing (#10844)
This commit is contained in:
@@ -45,6 +45,10 @@ def _diff(old, new, data_keys, with_missing=False):
|
|||||||
with_renames=True,
|
with_renames=True,
|
||||||
meta_cmp_key=meta_cmp_key,
|
meta_cmp_key=meta_cmp_key,
|
||||||
roots=data_keys,
|
roots=data_keys,
|
||||||
|
# we need to get unknown and unchanged entries to tell whether
|
||||||
|
# the object is missing from the cache or not.
|
||||||
|
with_unknown=with_missing,
|
||||||
|
with_unchanged=with_missing,
|
||||||
):
|
):
|
||||||
if (change.old and change.old.isdir and not change.old.hash_info) or (
|
if (change.old and change.old.isdir and not change.old.hash_info) or (
|
||||||
change.new and change.new.isdir and not change.new.hash_info
|
change.new and change.new.isdir and not change.new.hash_info
|
||||||
|
|||||||
+12
-2
@@ -265,12 +265,22 @@ def test_diff_no_cache(tmp_dir, scm, dvc):
|
|||||||
|
|
||||||
remove(dvc.cache.local.path)
|
remove(dvc.cache.local.path)
|
||||||
|
|
||||||
# invalidate_dir_info to force cache loading
|
diff = dvc.diff("v1")
|
||||||
dvc.cache.local._dir_info = {}
|
assert diff["added"] == []
|
||||||
|
assert diff["deleted"] == []
|
||||||
|
assert first(diff["modified"])["path"] == os.path.join("dir", "")
|
||||||
|
assert diff["renamed"] == []
|
||||||
|
assert diff["not in cache"] == [
|
||||||
|
{
|
||||||
|
"hash": "61d9c7f006e1ae7138fec5e574676ee2.dir",
|
||||||
|
"path": os.path.join("dir", ""),
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
diff = dvc.diff("v1", "v2")
|
diff = dvc.diff("v1", "v2")
|
||||||
assert diff["added"] == []
|
assert diff["added"] == []
|
||||||
assert diff["deleted"] == []
|
assert diff["deleted"] == []
|
||||||
|
assert diff["renamed"] == []
|
||||||
assert first(diff["modified"])["path"] == os.path.join("dir", "")
|
assert first(diff["modified"])["path"] == os.path.join("dir", "")
|
||||||
assert diff["not in cache"] == []
|
assert diff["not in cache"] == []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user