Skip to main content

Module git

Module git 

Source
Expand description

Git integration for the PR gate. Computes changed files (working tree + staged + optionally vs a base ref) and changed line ranges so findings can be attributed introduced-vs-inherited at line granularity (parsed from git diff --unified=0), with file-level as the fallback.

Functions§

changed_files
Return the set of changed file paths (relative to root), or None if this isn’t a git repo / git is unavailable. Includes unstaged, staged, untracked, and (if base is given) everything changed since the merge-base with base.
changed_lines
Added/modified line ranges per file (relative paths) from git diff --unified=0, combining unstaged + staged + (if base) the base range, plus whole-file ranges for untracked files. None if not a git repo. Enables line-level introduced-vs-inherited attribution.
file_churn
Per-file churn = number of commits that touched each file (relative paths). None if not a git repo. Used for churn×complexity hotspot ranking.
line_is_changed
Whether line of finding_path falls in a changed range from changed_lines.
path_is_changed
Whether a finding path (possibly absolute or ./-prefixed) is in the changed set (which holds paths relative to root).