Skip to main content

Module diff

Module diff 

Source
Expand description

Which files changed, in git terms.

Every command in drep that looks at “what changed” comes through here. drep check --staged for a pre-commit hook, --diff <ref> for a pre-push gate, and the cache key that deduplicates repeated LLM calls all need a stable answer to the same question. They shell out to git directly — tokio::process::Command rather than libgit2, because the only operations drep needs are the ones git’s own CLI was built for, and a git CLI that misbehaves would surface as a real OS-level error rather than a translated library one.

Two invariants matter more than the implementations:

  • “No files changed” must be distinct from “I could not ask git”. Conflating them is how a commit gate rubber-stamps the day the user’s git install breaks.
  • current_commit_sha is the one place this is reversed: it only feeds a cache key, and a cache-key component must never take the analysis down.

Modules§

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

Enums§

GitError
What went wrong shelling out to git.

Constants§

CONTEXT_LINES
How many lines of unchanged context to request around each change.

Functions§

changed_since
Files changed on this branch relative to git_ref, relative to root.
current_commit_sha
The current commit’s SHA, with "unknown" on any failure.
hunks_between
Hunks between git_ref and an explicit tip, or HEAD when tip is None.
hunks_since
Hunks for what this branch changed relative to git_ref.
staged_files
Files staged for commit, relative to root, that drep analyzes.
staged_hunks
Hunks for the files staged for commit.