@@ -581,11 +581,13 @@ async fn cmd_apply(
581581
582582 // Verify we're in a git repository
583583 let git_check = Command :: new ( "git" )
584- . args ( & [ "rev-parse" , "--git-dir" ] )
584+ . args ( [ "rev-parse" , "--git-dir" ] )
585585 . output ( ) ;
586586
587587 if git_check. is_err ( ) || !git_check. unwrap ( ) . status . success ( ) {
588- anyhow:: bail!( "Not in a git repository. Please run this command from within a git repository." ) ;
588+ anyhow:: bail!(
589+ "Not in a git repository. Please run this command from within a git repository."
590+ ) ;
589591 }
590592
591593 // Get the GitHub token
@@ -599,7 +601,7 @@ async fn cmd_apply(
599601 } else {
600602 // Try to detect from git remote
601603 let output = Command :: new ( "git" )
602- . args ( & [ "remote" , "get-url" , "origin" ] )
604+ . args ( [ "remote" , "get-url" , "origin" ] )
603605 . output ( )
604606 . context ( "Failed to get git remote origin" ) ?;
605607
@@ -610,13 +612,17 @@ async fn cmd_apply(
610612 let remote_url = String :: from_utf8_lossy ( & output. stdout ) . trim ( ) . to_string ( ) ;
611613
612614 // Parse GitHub URL (supports both HTTPS and SSH)
613- let repo = if let Some ( captures) = regex:: Regex :: new ( r"github\.com[:/](.+?/[^/]+?)(?:\.git)?$" )
614- . unwrap ( )
615- . captures ( & remote_url)
615+ let repo = if let Some ( captures) =
616+ regex:: Regex :: new ( r"github\.com[:/](.+?/[^/]+?)(?:\.git)?$" )
617+ . unwrap ( )
618+ . captures ( & remote_url)
616619 {
617620 captures. get ( 1 ) . unwrap ( ) . as_str ( ) . to_string ( )
618621 } else {
619- anyhow:: bail!( "Could not parse GitHub repository from remote URL: {}" , remote_url) ;
622+ anyhow:: bail!(
623+ "Could not parse GitHub repository from remote URL: {}" ,
624+ remote_url
625+ ) ;
620626 } ;
621627
622628 repo
@@ -636,42 +642,47 @@ async fn cmd_apply(
636642 let optimized_content = Optimizer :: optimize ( path, & report) ?;
637643
638644 // Create a new branch name
639- let filename = path. file_stem ( ) . and_then ( |s| s. to_str ( ) ) . unwrap_or ( "config" ) ;
645+ let filename = path
646+ . file_stem ( )
647+ . and_then ( |s| s. to_str ( ) )
648+ . unwrap_or ( "config" ) ;
640649 let branch_name = format ! ( "pipelinex-optimize-{}" , filename) ;
641650
642651 println ! ( "🌿 Creating branch: {}" , branch_name) ;
643652
644653 // Check if branch already exists
645654 let branch_exists = Command :: new ( "git" )
646- . args ( & [ "rev-parse" , "--verify" , & branch_name] )
655+ . args ( [ "rev-parse" , "--verify" , & branch_name] )
647656 . output ( )
648657 . ok ( )
649658 . map ( |o| o. status . success ( ) )
650659 . unwrap_or ( false ) ;
651660
652661 if branch_exists {
653- println ! ( "⚠️ Branch {} already exists. Switching to it..." , branch_name) ;
662+ println ! (
663+ "⚠️ Branch {} already exists. Switching to it..." ,
664+ branch_name
665+ ) ;
654666 Command :: new ( "git" )
655- . args ( & [ "checkout" , & branch_name] )
667+ . args ( [ "checkout" , & branch_name] )
656668 . status ( )
657669 . context ( "Failed to checkout existing branch" ) ?;
658670 } else {
659671 // Create and checkout new branch
660672 Command :: new ( "git" )
661- . args ( & [ "checkout" , "-b" , & branch_name] )
673+ . args ( [ "checkout" , "-b" , & branch_name] )
662674 . status ( )
663675 . context ( "Failed to create new branch" ) ?;
664676 }
665677
666678 // Write optimized config
667679 println ! ( "📝 Writing optimized configuration..." ) ;
668- std:: fs:: write ( path, & optimized_content)
669- . context ( "Failed to write optimized configuration" ) ?;
680+ std:: fs:: write ( path, & optimized_content) . context ( "Failed to write optimized configuration" ) ?;
670681
671682 // Commit changes
672683 println ! ( "💾 Committing changes..." ) ;
673684 Command :: new ( "git" )
674- . args ( & [ "add" , path. to_str ( ) . unwrap ( ) ] )
685+ . args ( [ "add" , path. to_str ( ) . unwrap ( ) ] )
675686 . status ( )
676687 . context ( "Failed to git add" ) ?;
677688
@@ -684,20 +695,21 @@ async fn cmd_apply(
684695 filename,
685696 report. findings. len( ) ,
686697 ( ( report. total_estimated_duration_secs - report. optimized_duration_secs)
687- / report. total_estimated_duration_secs * 100.0 ) ,
698+ / report. total_estimated_duration_secs
699+ * 100.0 ) ,
688700 report. total_estimated_duration_secs,
689701 report. optimized_duration_secs
690702 ) ;
691703
692704 Command :: new ( "git" )
693- . args ( & [ "commit" , "-m" , & commit_msg] )
705+ . args ( [ "commit" , "-m" , & commit_msg] )
694706 . status ( )
695707 . context ( "Failed to commit changes" ) ?;
696708
697709 // Push to remote
698710 println ! ( "⬆️ Pushing to remote..." ) ;
699711 Command :: new ( "git" )
700- . args ( & [ "push" , "-u" , "origin" , & branch_name] )
712+ . args ( [ "push" , "-u" , "origin" , & branch_name] )
701713 . status ( )
702714 . context ( "Failed to push branch" ) ?;
703715
@@ -711,7 +723,10 @@ async fn cmd_apply(
711723
712724 let parts: Vec < & str > = repo_name. split ( '/' ) . collect ( ) ;
713725 if parts. len ( ) != 2 {
714- anyhow:: bail!( "Invalid repository format. Expected owner/repo, got: {}" , repo_name) ;
726+ anyhow:: bail!(
727+ "Invalid repository format. Expected owner/repo, got: {}" ,
728+ repo_name
729+ ) ;
715730 }
716731 let ( owner, repo) = ( parts[ 0 ] , parts[ 1 ] ) ;
717732
@@ -733,10 +748,13 @@ async fn cmd_apply(
733748 path. display( ) ,
734749 report. findings. len( ) ,
735750 ( ( report. total_estimated_duration_secs - report. optimized_duration_secs)
736- / report. total_estimated_duration_secs * 100.0 ) ,
751+ / report. total_estimated_duration_secs
752+ * 100.0 ) ,
737753 report. total_estimated_duration_secs,
738754 report. optimized_duration_secs,
739- report. findings. iter( )
755+ report
756+ . findings
757+ . iter( )
740758 . take( 5 )
741759 . map( |f| format!( "- **{:?}**: {}" , f. severity, f. title) )
742760 . collect:: <Vec <_>>( )
0 commit comments