Skip to main content

Module git_helpers

Module git_helpers 

Source
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 removal
  • identity - Git identity resolution with comprehensive fallback chain
  • repo - Basic git repository operations (add, commit, snapshot)
  • start_commit - Starting commit tracking for incremental diffs
  • review_baseline - Per-review-cycle baseline tracking
  • wrapper - Agent phase git wrapper for safe concurrent execution
  • branch - Branch detection and default branch resolution
  • rebase - 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§

DiffReviewContent
The result of diff truncation for review purposes.
GitHelpers
Git helper state.
ProtectionCheckResult
Result of checking and self-healing agent-phase protections.
ProtectionScope

Enums§

CommitResultFallback
Result of commit operation with fallback.
DiffTruncationLevel
The level of truncation applied to a diff for review.
RebaseErrorKind
Detailed classification of rebase failure modes.
RebaseResult
Result of a rebase operation.
ReviewBaseline
StartPoint

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 patterns to .git/info/exclude that 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.