vendor: add summary output for crates vendored#16646
vendor: add summary output for crates vendored#16646raushan728 wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
While this change might be simple and straightforwards, our contributing guideline encourages starting from an issue and discussion first before posting a pull request: https://doc.crates.io/contrib/process/working-on-cargo.html#before-hacking-on-cargo
There was a problem hiding this comment.
Sorry about that i am still learning the workflow here. I'll make sure to start with an issue next time
There was a problem hiding this comment.
Adds a final status message to 'cargo vendor' showing the count of crates vendored and the destination directory. This improves consistency with other commands like 'cargo install'
I personally don't immediately see the value of consistency here. Other maintainers may have different opinions though.
There was a problem hiding this comment.
For example, count of binaries installed via cargo install is essentially as we might not want to accidentally install extra bins. But do people really know about how many dependencies they vendor? What is the actual summary people want to know when vendoring. This might be worthy some level of discussions.
There was a problem hiding this comment.
I thought a final confirmation would be helpful for large workspaces, but I'm open to suggestions if you think the summary should be different or is unnecessary
| Package::new("bar", "0.1.0").publish(); | ||
|
|
||
| p.cargo("vendor --respect-source-config") | ||
| .with_stderr_contains("[..]Vendored 1 crates into [..]vendor") |
There was a problem hiding this comment.
We recommend snapshot testing with with_stderr_data method as the primary way to assert snapshot. See https://doc.crates.io/contrib/tests/writing.html
There was a problem hiding this comment.
Thanks for the tip I've updated the test to use with_stderr_data and snapshot matching
|
hi @weihanglo fixed the tests and logic. also, sorry for skipping the issue process i am still learning the workflow. plz take a look |
6134403 to
a06c1d1
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
There was a problem hiding this comment.
Thanks!
Not sure if it's really worth adding it, as once you vendor all your crates, all the code will likely be checked into the VCS. You can easily track how many and which crates you have vendored. Especially for large workspaces, I guess this message may not be that helpful since we will vendor a lot of content.
If they want to know how many crates they vendored, they can simply count the directory count. (I'm not sure in what situation this information would be necessary.)
At least for go mod vendor -v, it does not have this kind of summary.
So I personally would prefer not to add it.
| } | ||
|
|
||
| #[cargo_test] | ||
| fn vendor_summary_output() { |
There was a problem hiding this comment.
Maybe we should try to vendor multiple crates in this test case. Otherwise, the tested logic is already covered by other tests, as you can see those tests already include Vendored 1 crate into vendor in their test output.
There was a problem hiding this comment.
Updated the test to vendor multiple crates
a06c1d1 to
0483c12
Compare
That makes sense. My intention here was mainly to provide a small UX improvement and keep it consistent with other commands like I agree that for large workspaces it might not add much value, but it could still be useful in smaller cases or scripting scenarios. If you think it's not worth showing by default, we can drop it. |
We do not recommend using status messages for scripting. They have no stability guarantee. |
| Vendoring baz v0.1.0 ([..]baz-0.1.0) to vendor/baz | ||
| Vendoring qux v0.1.0 ([..]qux-0.1.0) to vendor/qux | ||
| To use vendored sources, add this to your .cargo/config.toml for this project: | ||
|
|
There was a problem hiding this comment.
The other issue of this is that stout would have a example config output mixing with the added summary status in stderr.
Have you run it end-to-end and how would it look like? I assume it might be a bit messy though
There was a problem hiding this comment.
Have you run it end-to-end and how would it look like? I assume it might be a bit messy though
I ran it end-to-end, here's the actual output
/tmp/test-cargo-build-target/debug/cargo vendor
Updating crates.io index
Locking 18 packages to latest compatible versions
Adding rand v0.8.6 (available: v0.10.1)
Downloading crates ...
Downloaded wasi v0.11.1+wasi-snapshot-preview1
Downloaded rand v0.8.6
Vendoring cfg-if v1.0.4 (...) to /tmp/test-vendor/vendor/cfg-if
Vendoring getrandom v0.2.17 (...) to /tmp/test-vendor/vendor/getrandom
Vendoring libc v0.2.186 (...) to /tmp/test-vendor/vendor/libc
Vendoring log v0.4.29 (...) to /tmp/test-vendor/vendor/log
Vendoring ppv-lite86 v0.2.21 (...) to /tmp/test-vendor/vendor/ppv-lite86
Vendoring proc-macro2 v1.0.106 (...) to /tmp/test-vendor/vendor/proc-macro2
Vendoring quote v1.0.45 (...) to /tmp/test-vendor/vendor/quote
Vendoring rand v0.8.6 (...) to /tmp/test-vendor/vendor/rand
Vendoring rand_chacha v0.3.1 (...) to /tmp/test-vendor/vendor/rand_chacha
Vendoring rand_core v0.6.4 (...) to /tmp/test-vendor/vendor/rand_core
Vendoring serde v1.0.228 (...) to /tmp/test-vendor/vendor/serde
Vendoring serde_derive v1.0.228 (...) to /tmp/test-vendor/vendor/serde_derive
Vendoring syn v2.0.117 (...) to /tmp/test-vendor/vendor/syn
Vendoring unicode-ident v1.0.24 (...) to /tmp/test-vendor/vendor/unicode-ident
Vendoring wasi v0.11.1+wasi-snapshot-preview1 (...) to /tmp/test-vendor/vendor/wasi
Vendoring zerocopy v0.8.48 (...) to /tmp/test-vendor/vendor/zerocopy
Vendoring zerocopy-derive v0.8.48 (...) to /tmp/test-vendor/vendor/zerocopy-derive
To use vendored sources, add this to your .cargo/config.toml for this project:
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
Vendored 18 crates into vendorThere was a problem hiding this comment.
The output looks clean config snippet appears first, then the summary line at the end. No messy interleaving in practice. Happy to keep or drop based on your call.
There was a problem hiding this comment.
I think that is interleaving apparently from an end-user perspective.
- vendor: add summary output for crates vendored #16646 (comment)
- vendor: add summary output for crates vendored #16646 (review)
Since two maintainer have asked about the actual scenario here, and it seems pretty vague ("it could still be useful" without actual cases), I suggest we close this.
There was a problem hiding this comment.
We can move to an issue if you have your use cases in mind, and we discuss :)
Adds a final status message to 'cargo vendor' showing the count of crates vendored and the destination directory. This improves consistency with other commands like 'cargo install'