-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Problem
For lockfile versions, the schemas currently use Option<u32>. The problem with this is that it may become ambiguous when the version is null. Unsure if we should use ResolveVersion directly or define our own.
cargo-plumbing/crates/cargo-plumbing-schemas/src/lock_dependencies.rs
Lines 15 to 18 in be943f3
| pub enum LockDependenciesOut { | |
| Lockfile { | |
| version: Option<u32>, | |
| }, |
In #69, I noticed that resolve_with_previous can output a resolve with version ResolveVersion::V2. However, since ResolveVersion serializes V2 into a None, this results in a null version in the output messages.
I also noticed that using read-lockfile to read old Cargo.lock versions outputs a null as the version. I think this is fine, but what do we think of actually detecting versions to prevent null in the output messages?
cargo-plumbing/tests/testsuite/read_lockfile.rs
Lines 554 to 628 in be943f3
| #[cargo_test] | |
| fn old_lockfile() { | |
| let cksum = Package::new("a", "0.1.0").publish(); | |
| let p = project() | |
| .file("src/lib.rs", "") | |
| .file( | |
| "Cargo.toml", | |
| r#" | |
| [package] | |
| name = "foo" | |
| version = "0.0.1" | |
| edition = "2015" | |
| authors = [] | |
| [dependencies] | |
| a = "0.1.0" | |
| "#, | |
| ) | |
| .file( | |
| "Cargo.lock", | |
| &format!( | |
| r#" | |
| [root] | |
| name = "foo" | |
| version = "0.0.1" | |
| dependencies = [ | |
| "bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | |
| ] | |
| [[package]] | |
| name = "a" | |
| version = "0.1.0" | |
| source = "registry+https://github.com/rust-lang/crates.io-index" | |
| [metadata] | |
| "checksum a 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "{cksum}" | |
| "#, | |
| ), | |
| ) | |
| .build(); | |
| p.cargo_plumbing("plumbing read-lockfile") | |
| .arg("--lockfile-path") | |
| .arg(p.root().join("Cargo.lock")) | |
| .with_status(0) | |
| .with_stdout_data( | |
| str![[r#" | |
| [ | |
| { | |
| "reason": "lockfile", | |
| "version": null | |
| }, | |
| { | |
| "reason": "locked-package", | |
| "id": "registry+https://github.com/rust-lang/crates.io-index#[email protected]" | |
| }, | |
| { | |
| "reason": "locked-package", | |
| "id": "[email protected]", | |
| "dependencies": [ | |
| "registry+https://github.com/rust-lang/crates.io-index#[email protected]" | |
| ] | |
| }, | |
| { | |
| "reason": "metadata", | |
| "checksum a 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)": "3436ae58a84bb2033accec0cb50c6611f312249899579714793e0d0509470cd9" | |
| } | |
| ] | |
| "#]] | |
| .is_json() | |
| .against_jsonlines(), | |
| ) | |
| .run(); | |
| } |
Tasks
- Change
Option<u32>tou32in output messages (fix: RemoveOptionfrom lockfileversionout messages #98) - Use enum instead of
u32for versions