Skip to main content

ralph_workflow/git_helpers/
mod.rs

1//! Git Helper Functions
2//!
3//! Provides git hooks management, a git wrapper for blocking commits during the
4//! agent phase, and basic repository utilities.
5//!
6//! # Module Structure
7//!
8//! - [`hooks`] - Git hooks installation and removal
9//! - [`identity`] - Git identity resolution with comprehensive fallback chain
10//! - [`repo`] - Basic git repository operations (add, commit, snapshot)
11//! - [`start_commit`] - Starting commit tracking for incremental diffs
12//! - [`review_baseline`] - Per-review-cycle baseline tracking
13//! - [`wrapper`] - Agent phase git wrapper for safe concurrent execution
14//! - [`branch`] - Branch detection and default branch resolution
15//! - [`rebase`] - Rebase operations with fault tolerance
16
17#![deny(unsafe_code)]
18
19pub mod branch;
20mod hooks;
21pub mod identity;
22mod rebase;
23
24#[cfg(any(test, feature = "test-utils"))]
25pub mod rebase_checkpoint;
26
27#[cfg(any(test, feature = "test-utils"))]
28pub mod rebase_state_machine;
29
30mod repo;
31mod review_baseline;
32mod start_commit;
33mod wrapper;
34
35#[cfg(any(test, feature = "test-utils"))]
36pub use branch::get_default_branch_at;
37pub use branch::{get_default_branch, is_main_or_master_branch};
38pub use hooks::uninstall_hooks;
39#[cfg(any(test, feature = "test-utils"))]
40pub use hooks::{file_contains_marker_with_workspace, verify_hook_integrity_with_workspace};
41pub use rebase::{
42    abort_rebase, continue_rebase, get_conflict_markers_for_file, get_conflicted_files,
43    rebase_in_progress, rebase_onto, RebaseResult,
44};
45
46// Types that are part of the public API but not used in binary
47#[cfg(any(test, feature = "test-utils"))]
48pub use rebase::{CleanupResult, ConcurrentOperation};
49
50#[cfg(any(test, feature = "test-utils"))]
51pub use rebase::{
52    attempt_automatic_recovery, cleanup_stale_rebase_state, detect_concurrent_git_operations,
53    is_dirty_tree_cli, rebase_in_progress_cli, validate_rebase_preconditions,
54    verify_rebase_completed,
55};
56
57#[cfg(any(test, feature = "test-utils"))]
58pub use rebase::RebaseErrorKind;
59
60#[cfg(any(test, feature = "test-utils"))]
61pub use rebase_checkpoint::RebasePhase;
62
63#[cfg(any(test, feature = "test-utils"))]
64pub use rebase_state_machine::{RebaseLock, RebaseStateMachine};
65#[cfg(any(test, feature = "test-utils"))]
66pub use repo::{get_git_diff_from_start, git_diff_from};
67pub use repo::{
68    get_repo_root, git_add_all, git_commit, git_diff, git_snapshot, require_git_repo,
69    CommitResultFallback, DiffReviewContent, DiffTruncationLevel,
70};
71#[cfg(any(test, feature = "test-utils"))]
72pub use review_baseline::load_review_baseline_with_workspace;
73pub use review_baseline::{
74    get_baseline_summary, get_review_baseline_info, load_review_baseline, update_review_baseline,
75    ReviewBaseline,
76};
77#[cfg(any(test, feature = "test-utils"))]
78pub use start_commit::load_start_point_with_workspace;
79pub use start_commit::{
80    get_current_head_oid, get_start_commit_summary, load_start_point, reset_start_commit,
81    save_start_commit, StartPoint,
82};
83pub use wrapper::{
84    cleanup_agent_phase_silent, cleanup_orphaned_marker, disable_git_wrapper, end_agent_phase,
85    start_agent_phase, GitHelpers,
86};
87
88// Workspace-aware variants for testing
89#[cfg(any(test, feature = "test-utils"))]
90pub use wrapper::{
91    cleanup_orphaned_marker_with_workspace, create_marker_with_workspace,
92    marker_exists_with_workspace, remove_marker_with_workspace,
93};
94
95// Re-export checkpoint and recovery action for tests only
96#[cfg(any(test, feature = "test-utils"))]
97pub use rebase_checkpoint::RebaseCheckpoint;
98
99#[cfg(any(test, feature = "test-utils"))]
100pub use rebase_state_machine::RecoveryAction;
101
102#[cfg(test)]
103mod tests;