Skip to content

Commit b4c56a1

Browse files
authored
Include repository name in splicing errors (#3478)
Fixes #3460
1 parent 99c7b99 commit b4c56a1

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

crate_universe/extensions.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ def _generate_hub_and_spokes(
638638
config_path = config_file,
639639
output_dir = tag_path.get_child("splicing-output"),
640640
debug_workspace_dir = tag_path.get_child("splicing-workspace"),
641+
repository_name = cfg.name,
641642
)
642643

643644
# If a cargo lockfile was not provided, use the splicing lockfile.

crate_universe/private/crates_repository.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def _crates_repository_impl(repository_ctx):
8989
splicing_manifest = splicing_manifest,
9090
config_path = config_path,
9191
output_dir = repository_ctx.path("splicing-output"),
92+
repository_name = repository_ctx.name,
9293
)
9394

9495
kwargs.update({

crate_universe/private/splicing_utils.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def splice_workspace_manifest(
122122
splicing_manifest,
123123
config_path,
124124
output_dir,
125+
repository_name,
125126
debug_workspace_dir = None):
126127
"""Splice together a Cargo workspace from various other manifests and package definitions
127128
@@ -132,6 +133,7 @@ def splice_workspace_manifest(
132133
splicing_manifest (path): The path to a splicing manifest.
133134
config_path (path): The path to the config file (containing `cargo_bazel::config::Config`.)
134135
output_dir (path): THe location in which to write splicing outputs.
136+
repository_name (str): Name of the repository being generated.
135137
debug_workspace_dir (path): The location in which to save splicing outputs for future review.
136138
137139
Returns:
@@ -147,6 +149,8 @@ def splice_workspace_manifest(
147149
splicing_manifest,
148150
"--config",
149151
config_path,
152+
"--repository-name",
153+
repository_name,
150154
]
151155

152156
if cargo_lockfile:

crate_universe/src/cli/splice.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ pub struct SpliceOptions {
5757
/// The path to a rustc binary for use with Cargo
5858
#[clap(long, env = "RUSTC")]
5959
pub rustc: PathBuf,
60+
61+
/// The name of the repository being generated.
62+
#[clap(long)]
63+
pub repository_name: String,
6064
}
6165

6266
/// Combine a set of disjoint manifests into a single workspace.
@@ -84,7 +88,7 @@ pub fn splice(opt: SpliceOptions) -> Result<()> {
8488
// Splice together the manifest
8589
let manifest_path = splicer
8690
.splice_workspace()
87-
.context("Failed to splice workspace")?;
91+
.with_context(|| format!("Failed to splice workspace {}", opt.repository_name))?;
8892

8993
// Generate a lockfile
9094
let cargo_lockfile = generate_lockfile(

crate_universe/tests/cargo_integration_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ fn run(repository_name: &str, manifests: HashMap<String, String>, lockfile: &str
116116
config,
117117
cargo,
118118
rustc,
119+
repository_name: String::from("crates_index"),
119120
})
120121
.unwrap();
121122

0 commit comments

Comments
 (0)