Add new option --disable-quick-install-stats

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-07-25 00:12:35 +10:00 committed by Jiahao XU
parent 6df132a9d5
commit a908d3a6dd
6 changed files with 33 additions and 3 deletions

View file

@ -219,6 +219,14 @@ pub struct Args {
#[clap(help_heading = "Options", long)]
pub(crate) no_track: bool,
/// Disable statistics collection on popular crates.
///
/// Strategy quick-install (can be disabled via --disable-strategies) collects
/// statistics of popular crates by default, by sending the crate, version and
/// target to https://warehouse-clerk-tmp.vercel.app/api/crate
#[clap(help_heading = "Options", long)]
pub(crate) disable_quick_install_stats: bool,
/// Install binaries in a custom location.
///
/// By default, binaries are installed to the global location `$CARGO_HOME/bin`, and global
@ -611,5 +619,21 @@ mod test {
Args::command().debug_assert()
}
#[test]
fn quickinstall_url_matches() {
let long_help = Args::command()
.get_opts()
.find(|opt| opt.get_long() == Some("disable-quick-install-stats"))
.unwrap()
.get_long_help()
.unwrap()
.to_string();
assert!(
long_help.ends_with(binstalk::QUICK_INSTALL_STATS_URL),
"{}",
long_help
);
}
const _: () = assert!(Strategy::VARIANTS.len() == StrategyWrapped::VARIANTS.len());
}

View file

@ -207,6 +207,7 @@ pub fn install_crates(
} else {
SignaturePolicy::IfPresent
},
disable_quick_install_stats: args.disable_quick_install_stats,
});
// Destruct args before any async function to reduce size of the future