diff options
| author | Mohamed Hegazy <mhegazy@anthropic.com> | 2026-10-12 17:36:29 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-10-12 17:36:29 +0000 |
| commit | ed2ae7cd72fb60b4b3e58d622745870072cfd2aa (patch) | |
| tree | 155384ce450ed6dd08ce6012f1e9a2538b4e33bb /plugins/security-guidance/hooks/gitutil.py | |
| parent | ccdb984025c4115b7d534a41a9fdad43a5283f74 (diff) | |
security-guidance: count diff headers the parser could not readmhegazy/sg-diff-parsing
A file whose header cannot be parsed is left out of the review without a trace. The Stop hook now reports diff_hdr_unparsed (a count, only when nonzero) so a header shape the parser misses shows up in metrics.
Diffstat (limited to 'plugins/security-guidance/hooks/gitutil.py')
| -rw-r--r-- | plugins/security-guidance/hooks/gitutil.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/security-guidance/hooks/gitutil.py b/plugins/security-guidance/hooks/gitutil.py index 553ce8e0..93b7a87e 100644 --- a/plugins/security-guidance/hooks/gitutil.py +++ b/plugins/security-guidance/hooks/gitutil.py @@ -1030,6 +1030,12 @@ def _parse_diff_header(header): return old[2:], new[2:] +# Section headers that could not be parsed during this hook run; that file is +# left out of the review. The Stop hook reports the count so a header shape +# this parser misses shows up in telemetry instead of passing silently. +_unparsed_diff_headers = set() + + def _iter_diff_sections(diff_output): """Yield (new_path, lines after the header line) per file section.""" for section in _DIFF_SECTION_RE.split(diff_output)[1:]: @@ -1037,6 +1043,8 @@ def _iter_diff_sections(diff_output): paths = _parse_diff_header(lines[0]) if paths: yield paths[1] or paths[0], lines[1:] + else: + _unparsed_diff_headers.add(lines[0]) def extract_file_paths_from_diff(diff_output): |
