| 236 | |
| 237 | |
| 238 | def test_refs(tmp_dir, scm, dvc): |
| 239 | tmp_dir.dvc_gen("file", "first", commit="first version") |
| 240 | tmp_dir.dvc_gen("file", "second", commit="second version") |
| 241 | tmp_dir.dvc_gen("file", "third", commit="third version") |
| 242 | |
| 243 | HEAD_2 = digest("first") # noqa: N806 |
| 244 | HEAD_1 = digest("second") # noqa: N806 |
| 245 | HEAD = digest("third") # noqa: N806 |
| 246 | |
| 247 | assert dvc.diff("HEAD~1") == { |
| 248 | "added": [], |
| 249 | "deleted": [], |
| 250 | "modified": [{"path": "file", "hash": {"old": HEAD_1, "new": HEAD}}], |
| 251 | "not in cache": [], |
| 252 | "renamed": [], |
| 253 | } |
| 254 | |
| 255 | assert dvc.diff("HEAD~2", "HEAD~1") == { |
| 256 | "added": [], |
| 257 | "deleted": [], |
| 258 | "modified": [{"path": "file", "hash": {"old": HEAD_2, "new": HEAD_1}}], |
| 259 | "not in cache": [], |
| 260 | "renamed": [], |
| 261 | } |
| 262 | |
| 263 | with pytest.raises(DvcException, match=r"unknown Git revision 'missing'"): |
| 264 | dvc.diff("missing") |
| 265 | |
| 266 | |
| 267 | def test_directories(tmp_dir, scm, dvc): |