Skip to content

Conversation

UebelAndre
Copy link
Contributor

closes #687

@UebelAndre
Copy link
Contributor Author

@illicitonion @dae does this address the associated issue?

@dae
Copy link

dae commented Nov 29, 2022

I'm afraid I ended up switching over to using cargo directly, so am no longer affected by this, but the contents of the change seem correct, and I imagine this will be helpful to others.

@illicitonion
Copy link
Contributor

illicitonion commented Nov 29, 2022

Thanks for putting this together @UebelAndre!

I ran into two places where this doesn't quite solve my issue:

  1. It's actaully a per-package behaviour not a per-lockfile behaviour
  2. It doesn't just apply to registry sources - the dep.source.as_ref().unwrap().is_registry() filters out that git refs also need wiping
Here's one more Cargo.lock file which `cargo` thinks should cleanly round-trip with no diffs which `cargo-lock` doesn't
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "tower-buffer"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4887dc2a65d464c8b9b66e0e4d51c2fd6cf5b3373afc72805b0a60bce00446a"
dependencies = [
 "tracing 0.1.35",
]

[[package]]
name = "tracing"
version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"

[[package]]
name = "tracing"
version = "0.2.0"
source = "git+https://github.com/tokio-rs/tracing.git?rev=1e09e50e8d15580b5929adbade9c782a6833e4a0#1e09e50e8d15580b5929adbade9c782a6833e4a0"

[[package]]
name = "example"
version = "0.1.0"
dependencies = [
 "tower-buffer",
 "tracing 0.2.0",
]

And here's a modification of the input/output of your first added test:

Input
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3 

[[package]]
name = "bytes"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/alternate-index"
checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16"

[[package]]
name = "bytes"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"

[[package]]
name = "bytestring"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a"
dependencies = [ 
 "bytes 1.2.1",
 "external 1.0.0",
]

[[package]]
name = "example"
version = "0.1.0"
dependencies = [ 
 "bytes 0.6.0",
 "bytestring",
 "external 2.0.0",
]

[[package]]
name = "external"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30d69d242d4c4bc978b19d6c5f254cfb61ae3679c4656f528c9992fe337e45a6"

[[package]]
name = "external"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b5e0d8097cb9529731750ba339ea6813275b868779461ba1d39b841641386d9"
Output
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "bytes"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/alternate-index"
checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16"

[[package]]
name = "bytes"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"

[[package]]
name = "bytestring"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a"
dependencies = [
 "bytes 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "external 1.0.0",
]

[[package]]
name = "example"
version = "0.1.0"
dependencies = [
 "bytes 0.6.0 (registry+https://github.com/rust-lang/alternate-index)",
 "bytestring",
 "external 2.0.0",
]

[[package]]
name = "external"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30d69d242d4c4bc978b19d6c5f254cfb61ae3679c4656f528c9992fe337e45a6"

[[package]]
name = "external"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b5e0d8097cb9529731750ba339ea6813275b868779461ba1d39b841641386d9"

@UebelAndre
Copy link
Contributor Author

re: #767

Thanks! The pull request has been updated accordingly 😄

@tarcieri I think this change is ready for review. I'd tested locally but not sure if CI will reveal anything new.

Copy link
Member

@tarcieri tarcieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@UebelAndre
Copy link
Contributor Author

Thanks @tarcieri! Would it be possible to get a new release with this change in it as well?

@tarcieri tarcieri merged commit f35b5db into rustsec:main Dec 1, 2022
@tarcieri
Copy link
Member

tarcieri commented Dec 1, 2022

Sure

@UebelAndre UebelAndre deleted the lock branch December 1, 2022 00:36
@tarcieri tarcieri mentioned this pull request Dec 1, 2022
@tarcieri
Copy link
Member

tarcieri commented Dec 1, 2022

Released in v8.0.3

@UebelAndre
Copy link
Contributor Author

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo-lock: Seralize lockfiles without explicit registries
4 participants