Merge pull request from NobodyXu/fix-repeated-crates-on-batch-installation

Fix repeated crates on batch installation: Dedup them and only keep the last one
This commit is contained in:
Jiahao XU 2022-08-03 21:32:09 +10:00 committed by GitHub
commit f7625fcefc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 95 additions and 17 deletions

View file

@ -32,6 +32,9 @@ struct Options {
///
/// When multiple names are provided, the --version option and any override options are
/// unavailable due to ambiguity.
///
/// If duplicate names are provided, the last one (and their version requirement)
/// is kept.
#[clap(help_heading = "Package selection", value_name = "crate[@version]")]
crate_names: Vec<CrateName>,
@ -242,11 +245,14 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
""
};
if option != "" {
if !option.is_empty() {
return Err(BinstallError::OverrideOptionUsedWithMultiInstall { option }.into());
}
}
// Remove duplicate crate_name, keep the last one
let crate_names = CrateName::dedup(crate_names);
let cli_overrides = PkgOverride {
pkg_url: opts.pkg_url.take(),
pkg_fmt: opts.pkg_fmt.take(),