Skip to main content

collect_changed_paths

Function collect_changed_paths 

Source
pub fn collect_changed_paths(
    root: &Path,
    base: Option<&str>,
) -> Option<HashSet<PathBuf>>
Expand description

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.

base selects the diff:

  • Some("main")git diff --name-only --relative main...HEAD (three-dot — diff against the merge-base of main and HEAD). Right shape for PR-check use cases.
  • Nonegit ls-files --modified --others --exclude-standard from root. Right shape for pre-commit / local-dev use cases. Untracked-but-not-gitignored files are included so a freshly-added .env in the working tree shows up; deleted files are also returned (they’re in the diff but not on disk, so the engine’s intersect-with-walked-index step filters them out naturally).

Returns None on the same conditions as collect_tracked_paths: git not on PATH, root outside a repo, or the invocation exits non-zero. Callers should treat None as “no changed-set available” and fall back to a full check (or surface a hard error, depending on intent — alint check --changed errors out rather than fall back, so the user’s “diff-only” intent isn’t silently broken).