diff --git a/src/cargo/ops/vendor.rs b/src/cargo/ops/vendor.rs index 68af05ba49d..01c80b0ab79 100644 --- a/src/cargo/ops/vendor.rs +++ b/src/cargo/ops/vendor.rs @@ -41,7 +41,7 @@ pub fn vendor(ws: &Workspace<'_>, opts: &VendorOptions<'_>) -> CargoResult<()> { } let workspaces = extra_workspaces.iter().chain(Some(ws)).collect::>(); let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?; - let vendor_config = sync(gctx, &workspaces, opts).context("failed to sync")?; + let (vendor_config, count) = sync(gctx, &workspaces, opts).context("failed to sync")?; if gctx.shell().verbosity() != Verbosity::Quiet { if vendor_config.source.is_empty() { @@ -55,6 +55,13 @@ pub fn vendor(ws: &Workspace<'_>, opts: &VendorOptions<'_>) -> CargoResult<()> { } } + if count > 0 { + gctx.shell().status( + "Vendored", + format!("{} crates into {}", count, opts.destination.display()), + )?; + } + Ok(()) } @@ -121,7 +128,7 @@ fn sync( gctx: &GlobalContext, workspaces: &[&Workspace<'_>], opts: &VendorOptions<'_>, -) -> CargoResult { +) -> CargoResult<(VendorConfig, usize)> { let dry_run = false; let vendor_dir = try_canonicalize(opts.destination); let vendor_dir = vendor_dir.as_deref().unwrap_or(opts.destination); @@ -419,7 +426,7 @@ fn sync( paths::remove_dir(vendor_dir)?; } - Ok(VendorConfig { source: config }) + Ok((VendorConfig { source: config }, ids.len())) } fn cp_sources( diff --git a/tests/testsuite/build_scripts_multiple.rs b/tests/testsuite/build_scripts_multiple.rs index d3f06b111d9..8e5bb7e72be 100644 --- a/tests/testsuite/build_scripts_multiple.rs +++ b/tests/testsuite/build_scripts_multiple.rs @@ -357,6 +357,7 @@ fn verify_vendor_multiple_build_scripts() { [WARNING] ignoring `package.build` entry `build2.rs` as it is not included in the published package To use vendored sources, add this to your .cargo/config.toml for this project: + Vendored 1 crates into vendor "#]]) .run(); diff --git a/tests/testsuite/vendor.rs b/tests/testsuite/vendor.rs index 32cef245ff7..82ce68ada07 100644 --- a/tests/testsuite/vendor.rs +++ b/tests/testsuite/vendor.rs @@ -1989,6 +1989,7 @@ fn dont_delete_non_registry_sources_with_respect_source_config() { Vendoring log v0.3.5 ([ROOT]/foo/vendor/log) to new-vendor-dir/log To use vendored sources, add this to your .cargo/config.toml for this project: + Vendored 1 crates into new-vendor-dir "#]]) .with_stdout_data(str![[r#" @@ -2166,6 +2167,7 @@ fn vendor_local_registry() { Vendoring bar v0.0.0 ([ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.0) to vendor/bar To use vendored sources, add this to your .cargo/config.toml for this project: + Vendored 1 crates into vendor "#]]) .run(); @@ -2256,3 +2258,37 @@ fn vendor_filters_git_files_recursively() { assert!(!p.root().join("vendor/bar/.gitattributes").exists()); assert!(p.root().join("vendor/bar/src/lib.rs").exists()); } + +#[cargo_test] +fn vendor_summary_output() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = "0.1.0" + "#, + ) + .file("src/lib.rs", "") + .build(); + + Package::new("bar", "0.1.0").publish(); + + p.cargo("vendor --respect-source-config") + .with_stderr_data(str![[r#" +[UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version +[DOWNLOADING] crates ... +[DOWNLOADED] bar v0.1.0 (registry `[..]`) + Vendoring bar v0.1.0 ([..]bar-0.1.0) to vendor/bar +To use vendored sources, add this to your .cargo/config.toml for this project: + + Vendored 1 crates into vendor + +"#]]) + .run(); +}