output: preserve legacy hash_name on save() for unchanged data

This commit is contained in:
Peter Rowlands
2023-06-22 16:20:56 +09:00
committed by Peter Rowlands (변기호)
parent 77e35145a9
commit 90b9193250
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -692,7 +692,7 @@ class Output:
if self.metric:
self.verify_metric()
if self.hash_name == "md5-dos2unix":
if self.hash_name == "md5-dos2unix" and self.changed_checksum():
self.hash_name = "md5"
if self.use_cache:
_, self.meta, self.obj = build(
+4 -1
View File
@@ -316,9 +316,12 @@ def test_commit_dos2unix(tmp_dir, dvc):
}
)
legacy_content = (tmp_dir / "foo.dvc").read_text()
assert "hash: md5" not in legacy_content
dvc.commit("foo.dvc")
dvc.commit("foo.dvc", force=True)
assert (tmp_dir / "foo.dvc").read_text() == legacy_content
tmp_dir.gen("foo", "modified")
dvc.commit("foo.dvc", force=True)
content = (tmp_dir / "foo.dvc").read_text()
assert "hash: md5" in content