Skip to content

Include repository name in splicing errors #3478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crate_universe/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ def _generate_hub_and_spokes(
config_path = config_file,
output_dir = tag_path.get_child("splicing-output"),
debug_workspace_dir = tag_path.get_child("splicing-workspace"),
repository_name = cfg.name,
)

# If a cargo lockfile was not provided, use the splicing lockfile.
Expand Down
1 change: 1 addition & 0 deletions crate_universe/private/crates_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def _crates_repository_impl(repository_ctx):
splicing_manifest = splicing_manifest,
config_path = config_path,
output_dir = repository_ctx.path("splicing-output"),
repository_name = repository_ctx.name,
)

kwargs.update({
Expand Down
4 changes: 4 additions & 0 deletions crate_universe/private/splicing_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def splice_workspace_manifest(
splicing_manifest,
config_path,
output_dir,
repository_name,
debug_workspace_dir = None):
"""Splice together a Cargo workspace from various other manifests and package definitions

Expand All @@ -132,6 +133,7 @@ def splice_workspace_manifest(
splicing_manifest (path): The path to a splicing manifest.
config_path (path): The path to the config file (containing `cargo_bazel::config::Config`.)
output_dir (path): THe location in which to write splicing outputs.
repository_name (str): Name of the repository being generated.
debug_workspace_dir (path): The location in which to save splicing outputs for future review.

Returns:
Expand All @@ -147,6 +149,8 @@ def splice_workspace_manifest(
splicing_manifest,
"--config",
config_path,
"--repository-name",
repository_name,
]

if cargo_lockfile:
Expand Down
6 changes: 5 additions & 1 deletion crate_universe/src/cli/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ pub struct SpliceOptions {
/// The path to a rustc binary for use with Cargo
#[clap(long, env = "RUSTC")]
pub rustc: PathBuf,

/// The name of the repository being generated.
#[clap(long)]
pub repository_name: String,
}

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

// Generate a lockfile
let cargo_lockfile = generate_lockfile(
Expand Down
1 change: 1 addition & 0 deletions crate_universe/tests/cargo_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ fn run(repository_name: &str, manifests: HashMap<String, String>, lockfile: &str
config,
cargo,
rustc,
repository_name: String::from("crates_index"),
})
.unwrap();

Expand Down