Skip to main content

Module hunks

Module hunks 

Source
Expand description

Diff hunks: the structured form of a unified diff, and the parser that produces it.

A single git diff --unified=N output is just text, but everything that consumes it wants the same shape: a list of hunks, each tagged with its file and the line ranges it touches, and each line tagged with whether it was added, removed, or context. Parsing this once, here, means the callers (mod.rs queries, the payload renderer) never re-parse git’s output and never have to ask “what does +++ /dev/null mean again”.

The parser is deliberately tolerant. A diff that cannot be parsed must not take the gate down — it is much better to ship a partial answer than no answer — so anything not recognised is skipped rather than erroring.

Deliberately free of drep policy: this module answers “what does this diff say”, not “which files does drep review”. Whether a path is worth analyzing is a product decision, and it lives with the other git-semantics decisions in mod.rs beside filter_paths. Keeping it out of here is what lets the parser serve a future caller with a different scope (an include/exclude config, lint-docs) without threading a predicate through it.

Structs§

Hunk
One @@ hunk from a unified diff, with its file.

Enums§

HunkLine
One line inside a hunk, tagged by what the diff said about it.

Functions§

parse_unified_diff
Parse the output of git diff --unified=N into hunks.