diff --git a/module/move/willbe/src/action/publish.rs b/module/move/willbe/src/action/publish.rs index 94a6e940c6..0c775fb420 100644 --- a/module/move/willbe/src/action/publish.rs +++ b/module/move/willbe/src/action/publish.rs @@ -137,7 +137,7 @@ mod private None }; - let subgraph = graph::remove_not_required_to_publish( &package_map, &tmp, &packages_to_publish, dir.clone() ); + let subgraph = graph::remove_not_required_to_publish( &package_map, &tmp, &packages_to_publish, dir.clone() ).err_with( || report.clone() )?; let subgraph = subgraph.map( | _, n | n, | _, e | e ); let queue = graph::toposort( subgraph ).unwrap().into_iter().map( | n | package_map.get( &n ).unwrap() ).cloned().collect::< Vec< _ > >(); diff --git a/module/move/willbe/src/entity/package.rs b/module/move/willbe/src/entity/package.rs index 4fb858191e..0d987e5579 100644 --- a/module/move/willbe/src/entity/package.rs +++ b/module/move/willbe/src/entity/package.rs @@ -33,6 +33,7 @@ mod private use former::Former; use workspace::WorkspacePackage; use diff::crate_diff; + use error_tools::for_app::Error; /// #[ derive( Debug, Clone ) ] @@ -301,6 +302,18 @@ mod private pub commit : Option< process::Report >, pub push : Option< process::Report >, } + + impl std::fmt::Display for ExtendedGitReport + { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + let Self { add, commit, push } = &self; + if let Some( add ) = add { writeln!( f, "{add}" )? } + if let Some( commit ) = commit { writeln!( f, "{commit}" )? } + if let Some( push ) = push { writeln!( f, "{push}" )? } + + Ok( () ) + } + } #[ derive( Debug, Clone ) ] pub struct GitThingsOptions @@ -324,11 +337,11 @@ mod private .with_context( || format!("git_root: {}, item: {}", o.git_root.as_ref().display(), item.as_ref().display() ) ) ) .collect::< Result< Vec< _ > > >()?; - let res = git::add( &o.git_root, &items, o.dry ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + let res = git::add( &o.git_root, &items, o.dry ).map_err( | e | format_err!( "{report}\n{e}" ) )?; report.add = Some( res ); - let res = git::commit( &o.git_root, &o.message, o.dry ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + let res = git::commit( &o.git_root, &o.message, o.dry ).map_err( | e | format_err!( "{report}\n{e}" ) )?; report.commit = Some( res ); - let res = git::push( &o.git_root, o.dry ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + let res = git::push( &o.git_root, o.dry ).map_err( | e | format_err!( "{report}\n{e}" ) )?; report.push = Some( res ); Ok( report ) @@ -417,7 +430,7 @@ mod private /// # Returns /// /// * `Result` - The result of the publishing operation, including information about the publish, version bump, and git operations. - pub fn perform_package_publish( instruction : PackagePublishInstruction ) -> Result< PublishReport > + pub fn perform_package_publish( instruction : PackagePublishInstruction ) -> Result< PublishReport, ( PublishReport, Error ) > { let mut report = PublishReport::default(); let PackagePublishInstruction @@ -434,15 +447,15 @@ mod private git_things.dry = dry; publish.dry = dry; - report.get_info = Some( cargo::pack( pack ).map_err( | e | format_err!( "{report}\n{e:#?}" ) )? ); + report.get_info = Some( cargo::pack( pack ).map_err( | e | ( report.clone(), e ) )? ); // qqq : redundant field? report.publish_required = true; - report.bump = Some( version::version_bump( version_bump ).map_err( | e | format_err!( "{report}\n{e:#?}" ) )? ); - let git = perform_git_operations( git_things ).map_err( |e | format_err!( "{report}\n{e:#?}" ) )?; + report.bump = Some( version::version_bump( version_bump ).map_err( | e | ( report.clone(), e ) )? ); + let git = perform_git_operations( git_things ).map_err( | e | ( report.clone(), e ) )?; report.add = git.add; report.commit = git.commit; report.push = git.push; - report.publish = Some( cargo::publish( publish ).map_err( | e | format_err!( "{report}\n{e:#?}" ) )? ); + report.publish = Some( cargo::publish( publish ).map_err( | e | ( report.clone(), e ) )? ); Ok( report ) } @@ -620,7 +633,7 @@ mod private let mut report = vec![]; for package in plan.plans { - let res = perform_package_publish( package ).map_err( | e | format_err!( "{report:#?}\n{e:#?}" ) )?; + let res = perform_package_publish( package ).map_err( |( current_rep, e )| format_err!( "{}\n{current_rep}\n{e}", report.iter().map( | r | format!( "{r}" ) ).join( "\n" ) ) )?; report.push( res ); } diff --git a/module/move/willbe/src/tool/graph.rs b/module/move/willbe/src/tool/graph.rs index 9191e31117..5fedda7688 100644 --- a/module/move/willbe/src/tool/graph.rs +++ b/module/move/willbe/src/tool/graph.rs @@ -21,6 +21,7 @@ pub( crate ) mod private use petgraph::prelude::*; use error_tools::for_lib::Error; + use error::Result; use package::{ Package, publish_need }; #[ derive( Debug, Error ) ] @@ -242,7 +243,7 @@ pub( crate ) mod private roots : &[ String ], temp_path : Option< PathBuf >, ) - -> Graph< String, String > + -> Result< Graph< String, String > > { let mut nodes = HashSet::new(); let mut cleared_graph = Graph::new(); @@ -269,7 +270,7 @@ pub( crate ) mod private .option_temp_path( temp_path.clone() ) .dry( false ) .form() - ).unwrap(); + )?; if publish_need( package, temp_path.clone() ).unwrap() { nodes.insert( n ); @@ -294,7 +295,7 @@ pub( crate ) mod private } } - cleared_graph + Ok( cleared_graph ) } }