Expand description
Git-aware “changed files” filtering shared between fallow-cli and fallow-lsp.
Provides:
validate_git_reffor input validation at trust boundaries.ChangedFilesError/try_get_changed_files/get_changed_filesfor resolving a git ref into the set of changed files.filter_results_by_changed_filesfor narrowing anAnalysisResultsto issues in those files.filter_duplication_by_changed_filesfor narrowing aDuplicationReportto clone groups touching at least one changed file.
Both filters intentionally exclude dependency-level issues (unused deps, type-only deps, test-only deps) since “unused dependency” is a function of the entire import graph and can’t be attributed to individual changed files.
Enums§
- Changed
Files Error - Classification of a
git difffailure, so callers can pick their own wording (soft warning vs hard error) without re-parsing stderr.
Functions§
- filter_
duplication_ by_ changed_ files - Filter a duplication report to only retain clone groups where at least one instance belongs to a changed file. Families, mirrored directories, and stats are rebuilt from the surviving groups so consumers see consistent, correctly-scoped numbers.
- filter_
results_ by_ changed_ files - Filter
resultsto only include issues whose source file is inchanged_files. - get_
changed_ files - Get files changed since a git ref. Returns
Noneon git failure after printing a warning to stderr. Used by--changed-sinceand--file, where a failure falls back to full-scope analysis. - resolve_
git_ toplevel - Resolve the canonical git toplevel for
cwd. - set_
spawn_ hook - Install a spawn-hook for this module’s git subprocesses. Idempotent;
subsequent calls are no-ops. Called once from the CLI’s
main()so long-running watch sessions reap pending git children on Ctrl+C. Defaults toCommand::outputwhen not set; the function-pointer indirection costs nothing for embedders and tests that don’t install a hook. - try_
get_ changed_ files - Get files changed since a git ref. Returns
Err(with details) when the git invocation itself failed, so callers can choose between warn-and-ignore and hard-error behavior. - try_
get_ changed_ files_ with_ toplevel - Like
try_get_changed_files, but takes a pre-resolved canonicaltoplevelso callers (the LSP) can cache it across runs and avoid the extragit rev-parse --show-toplevelsubprocess on every save. - validate_
git_ ref - Validate a user-supplied git ref before passing it to
git diff.
Type Aliases§
- Changed
Files Spawn Hook - Function pointer signature used by
set_spawn_hookto intercept the short-runninggit rev-parse/git diff/git ls-filessubprocesses this module spawns. Lets the CLI route those git children through itsScopedChildregistry so a SIGINT delivered to the parent during watch mode (or any analysis) reaps them instead of letting them run to completion. Seecrates/cli/src/signal/and issue #477.