Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
fix: validate locked and frozen options correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Jul 19, 2024
1 parent 334efd0 commit db17b8d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/ops/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn info(
let ws = nearest_manifest_path
.as_ref()
.and_then(|root| Workspace::new(root, gctx).ok());
validate_locked_and_frozen_options(ws.is_some(), gctx)?;
let nearest_package = ws.as_ref().and_then(|ws| {
nearest_manifest_path
.as_ref()
Expand All @@ -48,8 +49,6 @@ pub fn info(
package_id = None;
}

validate_locked_and_frozen_options(package_id, gctx)?;

let msrv_from_nearest_manifest_path_or_ws =
try_get_msrv_from_nearest_manifest_or_ws(nearest_package, ws.as_ref());
// If the workspace does not have a specific Rust version,
Expand Down Expand Up @@ -364,12 +363,11 @@ fn api_registry(
}

fn validate_locked_and_frozen_options(
package_id: Option<PackageId>,
in_workspace: bool,
gctx: &GlobalContext,
) -> Result<(), anyhow::Error> {
let from_workspace = package_id.is_some();
// Only in workspace, we can use --frozen or --locked.
if !from_workspace {
if !in_workspace {
if gctx.locked() {
anyhow::bail!("the option `--locked` can only be used within a workspace");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
error: the option `--frozen` can only be used within a workspace
error: could not find `unknown` in registry `[ROOTURL]/registry`
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Updating `dummy-registry` index
error: the option `--locked` can only be used within a workspace
error: could not find `unknown` in registry `[ROOTURL]/registry`

0 comments on commit db17b8d

Please sign in to comment.