Skip to content

Don't read Cargo.toml.orig #1424

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

Merged
merged 1 commit into from
Jun 21, 2021
Merged
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
16 changes: 5 additions & 11 deletions crates/metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,14 @@ pub struct BuildTargets<'a> {
impl Metadata {
/// Read the `Cargo.toml` from a source directory, then parse the build metadata.
///
/// If both `Cargo.toml` and `Cargo.toml.orig` exist in the directory,
/// `Cargo.toml.orig` will take precedence.
///
/// If you already have the path to a TOML file, use [`Metadata::from_manifest`] instead.
pub fn from_crate_root<P: AsRef<Path>>(source_dir: P) -> Result<Metadata, MetadataError> {
let source_dir = source_dir.as_ref();
for &c in &["Cargo.toml.orig", "Cargo.toml"] {
let manifest_path = source_dir.join(c);
if manifest_path.exists() {
return Metadata::from_manifest(manifest_path);
}
let manifest_path = source_dir.as_ref().join("Cargo.toml");
if manifest_path.exists() {
Metadata::from_manifest(manifest_path)
} else {
Err(io::Error::new(io::ErrorKind::NotFound, "no Cargo.toml").into())
}

Err(io::Error::new(io::ErrorKind::NotFound, "no Cargo.toml").into())
}

/// Read the given file into a string, then parse the build metadata.
Expand Down