@@ -14,113 +14,11 @@ use git2::{
1414use rand:: Rng ;
1515use regex:: Regex ;
1616
17- // Merge options types
18- #[ derive( Debug , PartialEq , Clone , Copy ) ]
19- enum SquashedMergeHandling {
20- // Reset the branch to the parent branch
21- Reset ,
17+ mod error;
18+ mod types;
2219
23- // Skip merging the branch
24- Skip ,
25-
26- // Force a merge despite the squashed merge detection
27- Merge ,
28- }
29-
30- #[ derive( Debug , PartialEq , Clone , Copy ) ]
31- enum ReportLevel {
32- // Minimal reporting (just success/failure)
33- Minimal ,
34-
35- // Standard reporting (summary with counts)
36- Standard ,
37-
38- // Detailed reporting (all actions and their results)
39- Detailed ,
40- }
41-
42- enum MergeResult {
43- // Successfully merged with changes
44- Success ( String ) , // Contains the merge output message
45-
46- // Already up-to-date, no changes needed
47- AlreadyUpToDate ,
48-
49- // Merge conflict occurred
50- Conflict ( String ) , // Contains the conflict message
51- }
52-
53- // For API consistency, we create our own Error variants
54- trait ErrorExt {
55- #[ allow( dead_code) ]
56- fn from_str ( message : & str ) -> Self ;
57- fn merge_conflict ( branch : String , upstream : String , message : Option < String > ) -> Self ;
58- fn git_command_failed ( command : String , status : i32 , stdout : String , stderr : String ) -> Self ;
59- }
60-
61- impl ErrorExt for Error {
62- fn from_str ( message : & str ) -> Self {
63- Error :: from_str ( message)
64- }
65-
66- fn merge_conflict ( branch : String , upstream : String , message : Option < String > ) -> Self {
67- let mut error_msg = format ! ( "Merge conflict between {} and {}" , upstream, branch) ;
68- if let Some ( details) = message {
69- error_msg. push ( '\n' ) ;
70- error_msg. push_str ( & details) ;
71- }
72- Error :: from_str ( & error_msg)
73- }
74-
75- fn git_command_failed ( command : String , status : i32 , stdout : String , stderr : String ) -> Self {
76- let error_msg = format ! (
77- "Git command failed: {}\n Status: {}\n Stdout: {}\n Stderr: {}" ,
78- command, status, stdout, stderr
79- ) ;
80- Error :: from_str ( & error_msg)
81- }
82- }
83-
84- struct MergeOptions {
85- // Skip the merge of the root branch into the first branch
86- ignore_root : bool ,
87-
88- // Git merge options passed to all merge operations
89- merge_flags : Vec < String > ,
90-
91- // Whether to use fork point detection (more accurate but slower)
92- use_fork_point : bool ,
93-
94- // How to handle squashed merges (reset, skip, merge)
95- squashed_merge_handling : SquashedMergeHandling ,
96-
97- // Print verbose output
98- verbose : bool ,
99-
100- // Return to original branch after merging
101- return_to_original : bool ,
102-
103- // Use simple merge mode
104- simple_mode : bool ,
105-
106- // Level of detail in the final report
107- report_level : ReportLevel ,
108- }
109-
110- impl Default for MergeOptions {
111- fn default ( ) -> Self {
112- MergeOptions {
113- ignore_root : false ,
114- merge_flags : vec ! [ ] ,
115- use_fork_point : true ,
116- squashed_merge_handling : SquashedMergeHandling :: Reset ,
117- verbose : false ,
118- return_to_original : true ,
119- simple_mode : false ,
120- report_level : ReportLevel :: Standard ,
121- }
122- }
123- }
20+ use error:: ErrorExt ;
21+ use types:: * ;
12422
12523fn executable_name ( ) -> String {
12624 let name = std:: env:: current_exe ( )
@@ -201,18 +99,6 @@ fn print_rebase_error(executable_name: &str, branch: &str, upstream_branch: &str
20199 ) ;
202100}
203101
204- enum BranchSearchResult {
205- NotPartOfAnyChain ,
206- Branch ( Branch ) ,
207- }
208-
209- enum SortBranch {
210- First ,
211- Last ,
212- Before ( Branch ) ,
213- After ( Branch ) ,
214- }
215-
216102#[ derive( Clone , PartialEq ) ]
217103struct Branch {
218104 branch_name : String ,
@@ -818,20 +704,6 @@ struct GitChain {
818704 repo : Repository ,
819705}
820706
821- // Structure to hold merge commit information
822- #[ derive( Debug ) ]
823- struct MergeCommitInfo {
824- message : Option < String > ,
825- stats : Option < MergeStats > ,
826- }
827-
828- #[ derive( Debug ) ]
829- struct MergeStats {
830- files_changed : usize ,
831- insertions : usize ,
832- deletions : usize ,
833- }
834-
835707impl GitChain {
836708 fn init ( ) -> Result < Self , Error > {
837709 let name_of_current_executable = executable_name ( ) ;
0 commit comments