From 06f64f6cf0bd315a0329c65ef2b33cacd829d5ac Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 27 Jul 2022 14:39:43 -0500 Subject: [PATCH 1/3] fix(upgrade): Respect offline with lockfile loading --- src/bin/upgrade/upgrade.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bin/upgrade/upgrade.rs b/src/bin/upgrade/upgrade.rs index cc97cbe88e..c243f61e1c 100644 --- a/src/bin/upgrade/upgrade.rs +++ b/src/bin/upgrade/upgrade.rs @@ -143,7 +143,7 @@ fn exec(args: UpgradeArgs) -> CargoResult<()> { let manifests = args.resolve_targets()?; let locked = args .to_lockfile - .then(|| load_lockfile(&manifests)) + .then(|| load_lockfile(&manifests, args.offline)) .transpose()? .unwrap_or_default(); @@ -390,7 +390,10 @@ fn exec(args: UpgradeArgs) -> CargoResult<()> { Ok(()) } -fn load_lockfile(targets: &[cargo_metadata::Package]) -> CargoResult> { +fn load_lockfile( + targets: &[cargo_metadata::Package], + offline: bool, +) -> CargoResult> { // Get locked dependencies. For workspaces with multiple Cargo.toml // files, there is only a single lockfile, so it suffices to get // metadata for any one of Cargo.toml files. @@ -400,7 +403,11 @@ fn load_lockfile(targets: &[cargo_metadata::Package]) -> CargoResult Date: Wed, 27 Jul 2022 14:40:38 -0500 Subject: [PATCH 2/3] fix(upgrade): Update lockfile dependencies not from registry --- src/bin/upgrade/upgrade.rs | 6 +----- tests/cargo-upgrade/to_lockfile/out/one/Cargo.toml | 2 +- tests/cargo-upgrade/to_lockfile/stderr.log | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/bin/upgrade/upgrade.rs b/src/bin/upgrade/upgrade.rs index c243f61e1c..e7dd241321 100644 --- a/src/bin/upgrade/upgrade.rs +++ b/src/bin/upgrade/upgrade.rs @@ -411,11 +411,7 @@ fn load_lockfile( let result = cmd.exec()?; - let locked = result - .packages - .into_iter() - .filter(|p| p.source.is_some()) // Source is none for local packages - .collect::>(); + let locked = result.packages; Ok(locked) } diff --git a/tests/cargo-upgrade/to_lockfile/out/one/Cargo.toml b/tests/cargo-upgrade/to_lockfile/out/one/Cargo.toml index d4f8e640ad..aa9737989e 100644 --- a/tests/cargo-upgrade/to_lockfile/out/one/Cargo.toml +++ b/tests/cargo-upgrade/to_lockfile/out/one/Cargo.toml @@ -7,4 +7,4 @@ path = "../dummy.rs" [dependencies] my-package = "0.2.3" -three = { path = "../implicit/three", version = "0.1.0" } +three = { path = "../implicit/three", version = "0.1.5" } diff --git a/tests/cargo-upgrade/to_lockfile/stderr.log b/tests/cargo-upgrade/to_lockfile/stderr.log index e160e3a6a0..cd92ac3325 100644 --- a/tests/cargo-upgrade/to_lockfile/stderr.log +++ b/tests/cargo-upgrade/to_lockfile/stderr.log @@ -1,6 +1,6 @@ Checking one's dependencies Upgrading my-package: v0.2.0 -> v0.2.3 -warning: ignoring three, could not find package: not in lock file + Upgrading three: v0.1.0 -> v0.1.5 Checking three's dependencies Upgrading my-package: v0.2.0 -> v0.2.3 Checking two's dependencies From fb633e4589d5c4583986771f590cfce3b3844ed5 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 27 Jul 2022 06:47:39 -0500 Subject: [PATCH 3/3] fix(upgrade): Adjust responsibility for errors --- src/bin/upgrade/upgrade.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/upgrade/upgrade.rs b/src/bin/upgrade/upgrade.rs index e7dd241321..8a10aa5ad2 100644 --- a/src/bin/upgrade/upgrade.rs +++ b/src/bin/upgrade/upgrade.rs @@ -186,7 +186,7 @@ fn exec(args: UpgradeArgs) -> CargoResult<()> { let dependency = match Dependency::from_toml(&manifest_path, dep_key, dep_item) { Ok(dependency) => dependency, Err(err) => { - shell_warn(&format!("ignoring {}, invalid entry: {}", dep_key, err))?; + shell_warn(&format!("ignoring {}, unsupported entry: {}", dep_key, err))?; continue; } };