Skip to content
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

chore: improve error message to suggest --project-manifest #1334

Merged
merged 1 commit into from
Mar 10, 2024
Merged
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
6 changes: 3 additions & 3 deletions crates/cargo_utils/src/workspace_members.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use anyhow::Context;
use cargo_metadata::{Metadata, Package};
use std::path::Path;

pub fn get_manifest_metadata(manifest_path: &Path) -> anyhow::Result<cargo_metadata::Metadata> {
pub fn get_manifest_metadata(
manifest_path: &Path,
) -> Result<cargo_metadata::Metadata, cargo_metadata::Error> {
cargo_metadata::MetadataCommand::new()
.no_deps()
.manifest_path(manifest_path)
.exec()
.with_context(|| format!("invalid manifest {manifest_path:?}"))
}

/// Lookup all members of the current workspace
Expand Down
11 changes: 10 additions & 1 deletion crates/release_plz/src/args/repo_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ pub trait RepoCommand {
}

fn cargo_metadata(&self) -> anyhow::Result<cargo_metadata::Metadata> {
cargo_utils::get_manifest_metadata(&self.project_manifest())
let manifest = &self.project_manifest();
cargo_utils::get_manifest_metadata(manifest).map_err(|e| match e {
cargo_metadata::Error::CargoMetadata { stderr } => {
let stderr = stderr.trim();
anyhow::anyhow!("{stderr}. Use --project-manifest to specify the path to the manifest file if it's not in the current directory.")
}
_ => {
anyhow::anyhow!(e)
}
})
}

fn get_repo_url(&self, config: &Config) -> anyhow::Result<RepoUrl> {
Expand Down