Refactor: check --version and $crate@$version conflict in cargo-binstall (#2201)

* Rm Options::version_req

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Refactor filter_out_installed_crates

Detect conflict between --version and crate@version in it, instead of in resolve

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix entry.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix resolve.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix entry.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix fmt in entry.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Rm unused import in ops.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix fmt in entry.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

---------

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
Jiahao XU 2025-06-19 21:36:45 +10:00 committed by GitHub
parent 5de9e7fc28
commit 390406d635
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 24 deletions

View file

@ -3,7 +3,6 @@
use std::{path::PathBuf, sync::Arc, time::Duration};
use compact_str::CompactString;
use semver::VersionReq;
use crate::{
fetchers::{Data, Fetcher, SignaturePolicy, TargetDataErased},
@ -38,7 +37,6 @@ pub struct Options {
pub locked: bool,
pub no_track: bool,
pub version_req: Option<VersionReq>,
pub cargo_toml_fetch_override: Option<CargoTomlFetchOverride>,
pub cli_overrides: PkgOverride,

View file

@ -67,12 +67,7 @@ async fn resolve_inner(
) -> Result<Resolution, BinstallError> {
info!("Resolving package: '{}'", crate_name);
let version_req = match (&crate_name.version_req, &opts.version_req) {
(Some(version), None) => MaybeOwned::Borrowed(version),
(None, Some(version)) => MaybeOwned::Borrowed(version),
(Some(_), Some(_)) => Err(BinstallError::SuperfluousVersionOption)?,
(None, None) => MaybeOwned::Owned(VersionReq::STAR),
};
let version_req = crate_name.version_req.unwrap_or(VersionReq::STAR);
let version_req_str = version_req.to_compact_string();