Expand description
Best-effort git-tracking integration.
git_tracked_only rules opt in to filtering matches against the
repo’s tracked-paths set — i.e. the output of git ls-files.
That set is computed once per Engine::run
when at least one rule wants it and stashed on the rule
Context.
The set is advisory: alint never refuses to run because a
git invocation failed. If the directory isn’t a git repo, or
git isn’t on PATH, or the repo is empty, the set is None
and rules that consult it treat every walked entry as
“untracked.” Rules opting into git_tracked_only therefore
become silent no-ops in non-git settings — which is the right
default for “absence-style” rules whose intent is “don’t let
this be committed.”
Structs§
- Blame
Cache - Per-run cache of
git blameoutput, shared across rules so multiplegit_blame_agerules over overlappingpaths:re-use the parsed result instead of re-shelling-out. - Blame
Line - One line of
git blame --line-porcelainoutput: the 1-indexed final line number in the working-tree file, the authoring time of the commit that last touched the line (per.git-blame-ignore-revs, when present), and the line content with its trailing newline stripped. - Commit
Record - One commit in a
<since>..HEADrange, as returned bycommit_messages_in_range.shais the abbreviated SHA fromgit log --abbrev-commit(typically 7 chars; git auto-extends if the prefix is ambiguous in the local repo).messageis the full commit message (subject + body, separated by a blank line) with the trailing newline thatgit log --format=%Bappends already trimmed.
Enums§
- Commit
Range Error - Errors that distinguish “git is here but the range is invalid”
from “git isn’t here at all.” The rule layer uses this to hard-
fail on misconfiguration (a bad
since:ref, often a shallow- clone gotcha in CI) while silently no-op’ing in non-git directories.
Functions§
- blame_
lines - Run
git blame --line-porcelainforrel_path(relative toroot) and return oneBlameLineper source line. - collect_
changed_ paths - Resolve the set of paths that have changed in the working tree
(and optionally relative to a base ref), expressed as paths
relative to
root. - collect_
tracked_ paths - Resolve the repo’s tracked-paths set, relative to
root. - commit_
messages_ in_ range - Enumerate commits reachable from
HEADbut not fromsince, i.e. the standard<since>..HEADrange, oldest first. - dir_
has_ tracked_ files - Test whether
dir_rel(a relative-to-root directory path) “exists in git” — defined as: at least one tracked file lives underneath it. Used bydir_exists/dir_absentwhengit_tracked_only: trueis set. - head_
commit_ message - HEAD’s commit message, as a single string with newlines preserved between subject and body. The subject is the first line; everything after the first blank line is the body.