Skip to main content

Module gitutil

Module gitutil 

Source
Expand description

Shared git helpers for quality commands.

All helpers shell out to git (matching the style of crate::diff) and operate on the process working directory. Paths returned by these helpers are relative to the working directory (the repo prefix is stripped), so they line up with index-relative paths in .ctx/codebase.sqlite.

Functionsยง

changed_files_against
Get the set of files changed relative to reference.
changed_files_against_in
Dir-explicit variant of changed_files_against, for commands and tests that operate on an explicit project root instead of the process cwd.
churn_between_in
Count how many commits touched each file since since, optionally anchored with --until=<until> (any git log date spec).
churn_since
Count how many commits touched each file since since (a git log --since date spec, e.g. "6 months ago" or "2025-01-01").
head_commit_in
The current HEAD commit as (full sha, committer date).
is_dirty_in
Whether the working tree has uncommitted changes (staged, unstaged, or untracked), per git status --porcelain.
is_git_repo
Check if the current directory is inside a git repository.
is_git_repo_in
Dir-explicit variant of is_git_repo, for commands and tests that operate on an explicit project root instead of the process cwd.
repo_prefix
Get the path of the current directory relative to the repository root.
rev_list_first_parent_in
First-parent commit shas in range (e.g. abc123..HEAD), oldest first.
show_file
Get the contents of path (relative to the current directory) at reference, or None if the file does not exist at that revision.
show_file_in
Dir-explicit variant of show_file, for commands and tests that operate on an explicit project root instead of the process cwd.