Skip to content

Commit 3239a0e

Browse files
authored
Tell which workspace to clean up (#3706)
Now the user will see `INFO: Only the workspace's Cargo.toml is required in the `manifests` attribute of workspace `cargo_workspace`; the rest can be removed` Before it was not clear in which workspace this happened. Might not have been a problem for most users but it helped to cleanup the examples in this repo.
1 parent 8ba0872 commit 3239a0e

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

crate_universe/src/splicing/splicer.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ impl<'a> SplicerKind<'a> {
7171
.and_then(|path| manifests.get_key_value(path))
7272
{
7373
if manifests.len() > 1 {
74-
eprintln!("Only the workspace's Cargo.toml is required in the `manifests` attribute; the rest can be removed");
74+
let workspace_name = manifest
75+
.package
76+
.as_ref()
77+
.map(|p| p.name.as_str())
78+
.unwrap_or_else(|| {
79+
path.parent()
80+
.and_then(|p| p.file_name())
81+
.unwrap_or_else(|| path.file_name().unwrap_or("unknown"))
82+
});
83+
eprintln!("INFO: Only the workspace's Cargo.toml is required in the `manifests` attribute of workspace `{workspace_name}`; the rest can be removed");
7584
}
7685
Ok(Self::Workspace {
7786
path,

examples/crate_universe/MODULE.bazel

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,7 @@ crate_index_cargo_workspace.from_cargo(
338338
cargo_config = "//cargo_workspace:.cargo/config.toml",
339339
cargo_lockfile = "//cargo_workspace:Cargo.Bazel.lock",
340340
lockfile = "//cargo_workspace:cargo-bazel-lock.json",
341-
manifests = [
342-
"//cargo_workspace:Cargo.toml",
343-
"//cargo_workspace/num_printer:Cargo.toml",
344-
"//cargo_workspace/printer:Cargo.toml",
345-
"//cargo_workspace/rng:Cargo.toml",
346-
],
341+
manifests = ["//cargo_workspace:Cargo.toml"],
347342
)
348343
use_repo(
349344
crate_index_cargo_workspace,

examples/crate_universe/cargo_workspace/cargo-bazel-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)