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
35pub use branch::{get_default_branch, is_main_or_master_branch};
36#[cfg(any(test, feature = "test-utils"))]
37pub use branch::{get_default_branch_at, is_main_or_master_branch_at};
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, restore_from_reflog,
54    validate_post_rebase_with_checks, validate_rebase_preconditions, verify_rebase_completed,
55    PostRebaseValidationResult,
56};
57
58#[cfg(any(test, feature = "test-utils"))]
59pub use rebase::RebaseErrorKind;
60
61#[cfg(any(test, feature = "test-utils"))]
62pub use rebase_checkpoint::RebasePhase;
63
64#[cfg(any(test, feature = "test-utils"))]
65pub use rebase_state_machine::{RebaseLock, RebaseStateMachine};
66#[cfg(any(test, feature = "test-utils"))]
67pub use repo::{get_git_diff_from_start, git_diff_from};
68pub use repo::{
69    get_repo_root, git_add_all, git_commit, git_diff, git_snapshot, require_git_repo,
70    CommitResultFallback, DiffReviewContent, DiffTruncationLevel,
71};
72pub use review_baseline::{
73    get_baseline_summary, get_review_baseline_info, load_review_baseline, update_review_baseline,
74    ReviewBaseline,
75};
76#[cfg(any(test, feature = "test-utils"))]
77pub use review_baseline::{
78    load_review_baseline_with_workspace, update_review_baseline_with_workspace,
79};
80pub use start_commit::{
81    get_current_head_oid, get_start_commit_summary, load_start_point, reset_start_commit,
82    save_start_commit, StartPoint,
83};
84#[cfg(any(test, feature = "test-utils"))]
85pub use start_commit::{load_start_point_with_workspace, save_start_commit_with_workspace};
86pub use wrapper::{
87    cleanup_agent_phase_silent, cleanup_orphaned_marker, disable_git_wrapper, end_agent_phase,
88    start_agent_phase, GitHelpers,
89};
90
91// Workspace-aware variants for testing
92#[cfg(any(test, feature = "test-utils"))]
93pub use wrapper::{
94    cleanup_orphaned_marker_with_workspace, create_marker_with_workspace,
95    marker_exists_with_workspace, remove_marker_with_workspace,
96};
97
98// Re-export checkpoint and recovery action for tests only
99#[cfg(any(test, feature = "test-utils"))]
100pub use rebase_checkpoint::RebaseCheckpoint;
101
102#[cfg(any(test, feature = "test-utils"))]
103pub use rebase_state_machine::RecoveryAction;
104
105#[cfg(test)]
106mod tests;