Expand description
Git Helper Functions
Provides git hooks management, a git wrapper for blocking commits during the agent phase, and basic repository utilities.
Core git operations use libgit2 directly. Agent-phase defense-in-depth may also install a temporary PATH wrapper that intercepts the git CLI when available.
§Module Structure
hooks- Git hooks installation and removalidentity- Git identity resolution with comprehensive fallback chainrepo- Basic git repository operations (add, commit, snapshot)start_commit- Starting commit tracking for incremental diffsreview_baseline- Per-review-cycle baseline trackingwrapper- Agent phase git wrapper for safe concurrent executionbranch- Branch detection and default branch resolutionrebase- Rebase operations with fault tolerance
Re-exports§
pub use branch::get_default_branch;pub use branch::is_main_or_master_branch;
Modules§
- branch
- Git branch detection and default branch resolution.
- identity
- Git identity resolution with fallback chain.
Structs§
- Diff
Review Content - The result of diff truncation for review purposes.
- GitHelpers
- Git helper state.
- Protection
Check Result - Result of checking and self-healing agent-phase protections.
- Protection
Scope
Enums§
- Commit
Result Fallback - Result of commit operation with fallback.
- Diff
Truncation Level - The level of truncation applied to a diff for review.
- Rebase
Error Kind - Detailed classification of rebase failure modes.
- Rebase
Result - Result of a rebase operation.
- Review
Baseline - Start
Point
Constants§
- HOOK_
MARKER - Marker string for Ralph-managed hooks.
- RALPH_
HOOK_ NAMES - All hook names managed by Ralph.
Functions§
- abort_
rebase - Abort the current rebase operation.
- capture_
head_ oid - Capture the current HEAD OID and write it to
<git-dir>/ralph/head-oid.txt. - cleanup_
agent_ phase_ protections_ silent_ at - Best-effort cleanup for command exit paths that should preserve command outputs.
- cleanup_
agent_ phase_ silent - Best-effort cleanup for unexpected exits (Ctrl+C, early-return, panics).
- cleanup_
agent_ phase_ silent_ at - Best-effort cleanup using an explicit repo root.
- cleanup_
orphaned_ marker - Clean up orphaned enforcement marker.
- cleanup_
orphaned_ marker_ with_ workspace - Clean up orphaned marker file using workspace abstraction.
- cleanup_
orphaned_ wrapper_ at - Clean up orphaned wrapper temp dir from a prior crashed run.
- clear_
agent_ phase_ global_ state - Clear the process-global agent-phase state mutexes.
- continue_
rebase - Continue a rebase after conflict resolution.
- create_
marker_ with_ workspace - Create the agent phase marker file using workspace abstraction.
- detect_
unauthorized_ commit - Detect unauthorized commits by comparing current HEAD against stored OID.
- disable_
git_ wrapper - Disable git wrapper.
- end_
agent_ phase - End agent phase (removes marker file).
- end_
agent_ phase_ in_ repo - End agent phase for an explicit repository.
- ensure_
agent_ phase_ protections - Verify and restore agent-phase commit protections before each agent invocation.
- ensure_
local_ excludes - Add
patternsto.git/info/excludethat are not already present. - get_
baseline_ summary - Get a summary of the baseline state for display.
- get_
conflict_ markers_ for_ file - Extract conflict markers from a file.
- get_
conflicted_ files - Get a list of files that have merge conflicts.
- get_
current_ head_ oid - Get the current HEAD commit OID.
- get_
current_ head_ oid_ at - Get the current HEAD commit OID for an explicit repository root.
- get_
git_ diff_ for_ review_ with_ workspace - Get the diff content that should be shown to reviewers.
- get_
git_ diff_ from_ start - Get the git diff from the starting commit.
- get_
git_ diff_ from_ start_ with_ workspace - Get the git diff from the starting commit (workspace-aware).
- get_
hooks_ dir - Errors
- get_
repo_ root - Get the git repository root.
- get_
review_ baseline_ info - Get review baseline info: (
baseline_oid,commits_since,is_stale). - get_
start_ commit_ summary - Get a summary of the start commit state for display.
- git_
add_ all - Stage all changes.
- git_
add_ all_ in_ repo - Stage all changes in the repository discovered from
repo_root. - git_
add_ specific_ in_ repo - Stage specific files for commit.
- git_
commit - Create a commit.
- git_
commit_ in_ repo - Create a commit in the repository discovered from
repo_root. - git_
diff - Get the diff of all changes (unstaged and staged).
- git_
diff_ from - Generate a diff from a specific starting commit.
- git_
diff_ in_ repo - Get the diff of all changes (unstaged and staged) by discovering from an explicit path.
- git_
snapshot - Get a snapshot of the current git status.
- git_
snapshot_ in_ repo - Get a snapshot of git status for a specific repository root.
- install_
hooks_ in_ repo - Install Ralph-managed hooks for an explicit repository root.
- load_
review_ baseline - Load the review baseline from the working directory.
- load_
start_ point - Load the starting commit OID from the file.
- marker_
exists_ with_ workspace - Check if the agent phase marker file exists using workspace abstraction.
- parse_
git_ status_ paths - Extract repo-relative paths from a porcelain v1-style status snapshot.
- rebase_
in_ progress - Check if a rebase is currently in progress.
- rebase_
onto - Perform a rebase onto the specified upstream branch.
- reinstall_
hooks_ if_ tampered - Reinstall hooks if they have been tampered with or removed.
- remove_
marker_ with_ workspace - Remove the agent phase marker file using workspace abstraction.
- require_
git_ repo - Check if we’re in a git repository.
- reset_
start_ commit - Reset the starting commit to merge-base with the default branch.
- resolve_
protection_ scope - Resolve the active git-protection scope for the current repository context.
- resolve_
protection_ scope_ from - Resolve the active git-protection scope for an explicit discovery root.
- save_
start_ commit - Save the current HEAD commit as the starting commit.
- save_
start_ commit_ with_ workspace - Save start commit using workspace abstraction.
- start_
agent_ phase - Start agent phase (creates marker file, installs hooks, enables wrapper).
- start_
agent_ phase_ in_ repo - Start agent phase for an explicit repository root.
- try_
remove_ ralph_ dir - Best-effort removal of the ralph git directory after all artifacts are cleaned.
- uninstall_
hooks - Uninstall all Ralph-managed hooks.
- uninstall_
hooks_ in_ repo - Uninstall all Ralph-managed hooks in an explicit repository.
- uninstall_
hooks_ silent_ in_ hooks_ dir - Silently uninstall Ralph-managed hooks from an explicitly provided hooks directory.
- update_
review_ baseline - Update the review baseline to the current HEAD.
- update_
review_ baseline_ with_ workspace - Update the review baseline using the workspace abstraction.
- verify_
hooks_ removed - Verify that no Ralph-managed hooks remain after cleanup.
- verify_
ralph_ dir_ removed - Verify that the Ralph metadata dir itself has been removed.
- verify_
wrapper_ cleaned - Verify that the wrapper temp dir and track file have been cleaned up.