(rel_path: str, spec: TargetSpec)
| 298 | |
| 299 | |
| 300 | def target_spec_matches_path(rel_path: str, spec: TargetSpec) -> bool: |
| 301 | rel_path = rel_path.replace("\\", "/") |
| 302 | |
| 303 | kind = spec["kind"] |
| 304 | normalized = spec["normalized"] |
| 305 | |
| 306 | if kind == "invalid": |
| 307 | return False |
| 308 | |
| 309 | if kind == "file": |
| 310 | return rel_path == normalized |
| 311 | |
| 312 | if kind == "dir": |
| 313 | return rel_path == normalized or rel_path.startswith(normalized + "/") |
| 314 | |
| 315 | if kind == "glob": |
| 316 | # Intentionally use simple shell-style matching here so patterns like |
| 317 | # docs/**/*.md behave the way users generally expect across platforms. |
| 318 | return fnmatch.fnmatchcase(rel_path, normalized) |
| 319 | |
| 320 | return False |
| 321 | |
| 322 | |
| 323 | def target_matches(rel_path: str, specs: list[TargetSpec] | None) -> bool: |
no outgoing calls
no test coverage detected