From b801802f579ec8cff8e9ccda140a03a99ee0d98e Mon Sep 17 00:00:00 2001 From: Barsik Date: Mon, 8 Apr 2024 14:07:43 +0300 Subject: [PATCH] Update cargo pack options to accommodate dirty crates Modified the cargo pack options to include two new fields, `allow_dirty` and `no_verify`. These options are now checked while executing the `.publish.diff` command and the `.publish` command when the `dry` option is enabled. This change allows for the packaging of crates even when they are in a "dirty" state, improving functionality by accommodating scenarios where perfection isn't strictly required. --- module/move/willbe/src/action/publish_diff.rs | 2 +- .../move/willbe/src/action/readme_modules_headers_renew.rs | 2 +- module/move/willbe/src/entity/features.rs | 1 - module/move/willbe/src/entity/package.rs | 2 ++ module/move/willbe/src/tool/cargo.rs | 6 ++++++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/module/move/willbe/src/action/publish_diff.rs b/module/move/willbe/src/action/publish_diff.rs index 010d9c7ead..0aec92732d 100644 --- a/module/move/willbe/src/action/publish_diff.rs +++ b/module/move/willbe/src/action/publish_diff.rs @@ -29,7 +29,7 @@ mod private let name = &package.name()?; let version = &package.version()?; - _ = cargo::pack( cargo::PackOptions::former().path( dir.as_ref() ).dry( false ).form() )?; + _ = cargo::pack( cargo::PackOptions::former().path( dir.as_ref() ).allow_dirty( true ).no_verify( true ).dry( false ).form() )?; let l = CrateArchive::read( packed_crate::local_path( name, version, dir )? )?; let r = CrateArchive::download_crates_io( name, version ).unwrap(); diff --git a/module/move/willbe/src/action/readme_modules_headers_renew.rs b/module/move/willbe/src/action/readme_modules_headers_renew.rs index 39237fcb12..2be1eab6a8 100644 --- a/module/move/willbe/src/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/action/readme_modules_headers_renew.rs @@ -12,7 +12,7 @@ mod private use std::borrow::Cow; use std::fs::{ OpenOptions }; use std::io::{ Read, Seek, SeekFrom, Write }; - use std::path::{Path, PathBuf}; + use std::path::PathBuf; use convert_case::{ Case, Casing }; use regex::Regex; use crate::action::readme_health_table_renew::find_example_file; diff --git a/module/move/willbe/src/entity/features.rs b/module/move/willbe/src/entity/features.rs index a292b131b1..81c1452180 100644 --- a/module/move/willbe/src/entity/features.rs +++ b/module/move/willbe/src/entity/features.rs @@ -2,7 +2,6 @@ mod private { use crate::*; use std::collections::{ BTreeSet, HashSet }; - use error_tools::err; // aaa : for Petro : don't use cargo_metadata and Package directly, use facade // aaa : ✅ use error_tools::for_app::{ bail, Result }; diff --git a/module/move/willbe/src/entity/package.rs b/module/move/willbe/src/entity/package.rs index 4fb858191e..b58718b0f5 100644 --- a/module/move/willbe/src/entity/package.rs +++ b/module/move/willbe/src/entity/package.rs @@ -367,6 +367,8 @@ mod private let pack = cargo::PackOptions { path : crate_dir.as_ref().into(), + allow_dirty : self.dry, + no_verify : self.dry, temp_path : self.base_temp_dir.clone(), dry : self.dry, }; diff --git a/module/move/willbe/src/tool/cargo.rs b/module/move/willbe/src/tool/cargo.rs index 83e376f59b..6a078e0eab 100644 --- a/module/move/willbe/src/tool/cargo.rs +++ b/module/move/willbe/src/tool/cargo.rs @@ -14,6 +14,10 @@ mod private pub struct PackOptions { pub( crate ) path : PathBuf, + #[ default( false ) ] + pub( crate ) allow_dirty : bool, + #[ default( false ) ] + pub( crate ) no_verify : bool, pub( crate ) temp_path : Option< PathBuf >, pub( crate ) dry : bool, } @@ -33,6 +37,8 @@ mod private { [ "package".to_string() ] .into_iter() + .chain( if self.allow_dirty { Some( "--allow-dirty".to_string() ) } else { None } ) + .chain( if self.no_verify { Some( "--no-verify".to_string() ) } else { None } ) .chain( self.temp_path.clone().map( | p | vec![ "--target-dir".to_string(), p.to_string_lossy().into() ] ).into_iter().flatten() ) .collect() }