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.

§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

§Diff Truncation

This module provides diff truncation for LLM consumption via truncate_diff_for_review. Large diffs are truncated to prevent exceeding LLM context limits:

  • Warning threshold ([MAX_DIFF_SIZE_WARNING]): 100KB - logs a warning
  • Hard limit: 1MB - truncates the diff

When truncation occurs, a marker is prepended to the diff content to inform the LLM reviewer that the context is incomplete.

Re-exports§

pub use branch::get_default_branch;
pub use branch::is_main_or_master_branch;
pub use rebase_checkpoint::RebasePhase;
pub use rebase_state_machine::RebaseLock;
pub use rebase_state_machine::RebaseStateMachine;

Modules§

branch
Git branch detection and default branch resolution.
identity
Git identity resolution with fallback chain.
rebase_checkpoint
Rebase checkpoint system for fault tolerance.
rebase_state_machine
Rebase state machine for fault-tolerant rebase operations.

Structs§

DiffReviewContent
The result of diff truncation for review purposes.
GitHelpers
Git helper state.

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
Review baseline state.
StartPoint

Functions§

abort_rebase
Abort the current rebase operation.
cleanup_agent_phase_silent
Best-effort cleanup for unexpected exits (Ctrl+C, early-return, panics).
cleanup_orphaned_marker
Clean up orphaned .no_agent_commit marker.
cleanup_stale_rebase_state
Clean up stale rebase state files.
continue_rebase
Continue a rebase after conflict resolution.
detect_concurrent_git_operations
Detect concurrent Git operations that would block a rebase.
disable_git_wrapper
Disable git wrapper.
end_agent_phase
End agent phase (removes marker file).
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_git_diff_from_review_baseline
Get the diff from the review baseline (or start commit if baseline not set).
get_repo_root
Get the git repository root.
get_review_baseline_info
Get information about the current review baseline.
get_start_commit_summary
Get a summary of the start commit state for display.
git_add_all
Stage all changes.
git_commit
Create a commit.
git_diff
Get the diff of all changes (unstaged and staged).
git_snapshot
Get a snapshot of the current git status.
load_review_baseline
Load the review baseline.
load_start_point
Load the starting commit OID from the file.
rebase_onto
Perform a rebase onto the specified upstream branch.
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.
save_start_commit
Save the current HEAD commit as the starting commit.
start_agent_phase
Start agent phase (creates marker file, installs hooks, enables wrapper).
truncate_diff_for_review
Truncate a diff for review using progressive fallback strategy.
uninstall_hooks
Uninstall all Ralph-managed hooks.
update_review_baseline
Update the review baseline to current HEAD.
validate_git_state
Validate the overall Git repository state for corruption.
validate_post_rebase_state
Validate that the repository is in a good state after rebase.
validate_rebase_preconditions
Validate preconditions before starting a rebase operation.