|
14 | 14 | import hashlib |
15 | 15 | import json |
16 | 16 | import os |
17 | | -from collections.abc import Iterable, Mapping |
| 17 | +from collections.abc import Mapping |
18 | 18 | from dataclasses import dataclass |
19 | 19 | from pathlib import Path |
20 | 20 | from types import MappingProxyType |
@@ -64,15 +64,18 @@ def fingerprint(*parts: str) -> str: |
64 | 64 | return digest.hexdigest() |
65 | 65 |
|
66 | 66 |
|
67 | | -def directory_fingerprint(directory: Path, suffixes: Iterable[str] = (".py", ".toml")) -> str: |
68 | | - """A digest of the source files under ``directory``, so edited plugin code misses.""" |
| 67 | +def directory_fingerprint(directory: Path) -> str: |
| 68 | + """A digest of every file under ``directory``, so an edited plugin misses: its code, |
| 69 | + its manifest and the rule or advisory data it ships in any format. Bytecode and |
| 70 | + hidden files are not part of what the plugin does.""" |
69 | 71 |
|
70 | | - wanted = tuple(suffixes) |
71 | 72 | parts: list[str] = [] |
72 | 73 | for path in sorted(directory.rglob("*")): |
73 | | - if path.is_file() and path.suffix in wanted: |
74 | | - parts.append(str(path.relative_to(directory))) |
75 | | - parts.append(path.read_text(encoding="utf-8", errors="replace")) |
| 74 | + relative = path.relative_to(directory) |
| 75 | + if not path.is_file() or any(p == "__pycache__" or p.startswith(".") for p in relative.parts): |
| 76 | + continue |
| 77 | + parts.append(str(relative)) |
| 78 | + parts.append(path.read_bytes().hex()) |
76 | 79 | return fingerprint(*parts) |
77 | 80 |
|
78 | 81 |
|
|
0 commit comments