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

Bump dep on semver to 1.0.0 #427

Merged
merged 3 commits into from
Aug 25, 2021
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
61 changes: 39 additions & 22 deletions impl/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ path = "src/bin/cargo-raze.rs"

[dependencies]
anyhow = "1.0.38"
cargo_metadata = "0.12.3"
cargo_metadata = "0.14"
cargo_toml = "0.8.1"
cargo-clone-crate = { version = "0.1.6", default-features = false }
cargo-lock = "6.0.0"
cargo-lock = "7"
cargo-platform = "0.1.1"
cfg-expr = "0.6.0"
crates-index = "0.16.2"
crates-index = "0.17"
docopt = "1.1.0"
glob = "0.3.0"
itertools = "0.10.0"
log = "0.4.13"
pathdiff = "0.2.0"
regex = "1.4.3"
rustc-serialize = "0.3.24"
semver = { version = "0.11.0", features = ["serde"] }
semver = { version = "1", features = ["serde"] }
serde = "1.0.120"
serde_derive = "1.0.120"
serde_json = "1.0.61"
Expand Down
16 changes: 9 additions & 7 deletions impl/src/bin/cargo-raze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ fn fetch_raze_metadata(
None => RazeMetadataFetcher::default(),
};

let cargo_raze_working_dir =
find_bazel_workspace_root(&local_metadata.workspace_root).unwrap_or(env::current_dir()?);
let cargo_raze_working_dir = find_bazel_workspace_root(local_metadata.workspace_root.as_ref())
.unwrap_or(env::current_dir()?);

let binary_dep_info = if settings.genmode == GenMode::Remote {
Some(&settings.binary_deps)
Expand All @@ -195,15 +195,17 @@ fn fetch_raze_metadata(

let reused_lockfile = if !options.flag_generate_lockfile.unwrap_or(false) {
find_lockfile(
&local_metadata.workspace_root,
&cargo_raze_working_dir.join(settings.workspace_path.trim_start_matches('/')),
local_metadata.workspace_root.as_ref(),
cargo_raze_working_dir
.join(settings.workspace_path.trim_start_matches('/'))
.as_ref(),
)
} else {
None
};

let raze_metadata = metadata_fetcher.fetch_metadata(
&local_metadata.workspace_root,
local_metadata.workspace_root.as_ref(),
binary_dep_info,
reused_lockfile,
)?;
Expand All @@ -227,8 +229,8 @@ fn render_files(
planned_build: &PlannedBuild,
local_metadata: &Metadata,
) -> Result<(RenderDetails, Vec<FileOutputs>)> {
let cargo_raze_working_dir =
find_bazel_workspace_root(&local_metadata.workspace_root).unwrap_or(env::current_dir()?);
let cargo_raze_working_dir = find_bazel_workspace_root(local_metadata.workspace_root.as_ref())
.unwrap_or(env::current_dir()?);

let mut bazel_renderer = BazelRenderer::new();
let render_details = RenderDetails {
Expand Down
3 changes: 1 addition & 2 deletions impl/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ impl RazeMetadataFetcher {

// Copy over the Cargo.toml files of each workspace member
self.link_src_to_workspace(&no_deps_metadata, temp_dir.as_ref())?;

Ok((temp_dir, no_deps_metadata.workspace_root))
Ok((temp_dir, no_deps_metadata.workspace_root.into()))
}

/// Download a crate's source code from the current registry url
Expand Down
4 changes: 2 additions & 2 deletions impl/src/planning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,12 +809,12 @@ mod tests {
assert!(planned_build
.crate_contexts
.iter()
.any(|ctx| ctx.pkg_name == "unicode-xid" && ctx.pkg_version == Version::from((0, 1, 0))));
.any(|ctx| ctx.pkg_name == "unicode-xid" && ctx.pkg_version == Version::new(0, 1, 0)));

assert!(planned_build
.crate_contexts
.iter()
.any(|ctx| ctx.pkg_name == "unicode-xid" && ctx.pkg_version == Version::from((0, 2, 1))));
.any(|ctx| ctx.pkg_name == "unicode-xid" && ctx.pkg_version == Version::new(0, 2, 1)));
}
// TODO(acmcarther): Add tests:
// TODO(acmcarther): Extra flags work
Expand Down
18 changes: 9 additions & 9 deletions impl/src/planning/subplanners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl<'planner> WorkspaceSubplanner<'planner> {
None
} else {
util::get_workspace_member_path(
&pkg.manifest_path,
&self.metadata.metadata.workspace_root,
pkg.manifest_path.as_ref(),
self.metadata.metadata.workspace_root.as_ref(),
)
}
} else {
Expand Down Expand Up @@ -257,7 +257,7 @@ impl<'planner> WorkspaceSubplanner<'planner> {
.get(&target)
.map(|x| x.to_string())
.unwrap_or(pkg_name);
let dep_alias = DependencyAlias { alias, target };
let dep_alias = DependencyAlias { target, alias };

to_alias
.raze_settings
Expand Down Expand Up @@ -313,8 +313,8 @@ impl<'planner> CrateSubplanner<'planner> {
.collect();

Ok(CrateTargetedDepContext {
deps,
target,
deps,
platform_targets,
})
})
Expand Down Expand Up @@ -347,14 +347,14 @@ impl<'planner> CrateSubplanner<'planner> {
.unwrap();

let workspace_member_path = util::get_workspace_member_path(
&member.manifest_path,
&self.crate_catalog.metadata.workspace_root,
member.manifest_path.as_ref(),
self.crate_catalog.metadata.workspace_root.as_ref(),
)
.ok_or_else(|| {
anyhow!(
"Failed to generate workspace_member_path for {} and {}",
&package.manifest_path.display(),
&self.crate_catalog.metadata.workspace_root.display()
&package.manifest_path,
&self.crate_catalog.metadata.workspace_root
)
})?;

Expand Down Expand Up @@ -642,7 +642,7 @@ impl<'planner> CrateSubplanner<'planner> {
let manifest_parent = package.manifest_path.parent().unwrap();
let path_to_crate_root = manifest_parent.strip_prefix(package_root).unwrap();
let path_to_crate_root = if path_to_crate_root.components().next().is_some() {
Some(path_to_crate_root.to_string_lossy().to_string())
Some(path_to_crate_root.to_string())
} else {
None
};
Expand Down
10 changes: 3 additions & 7 deletions impl/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,8 @@ pub struct LegacyCargoToml {
fn parse_raze_settings_legacy(metadata: &Metadata) -> Result<RazeSettings> {
let root_toml = metadata.workspace_root.join("Cargo.toml");
let toml_contents = std::fs::read_to_string(&root_toml)?;
let data = toml::from_str::<LegacyCargoToml>(&toml_contents).with_context(|| {
format!(
"Failed to read `[raze]` settings from {}",
root_toml.display()
)
})?;
let data = toml::from_str::<LegacyCargoToml>(&toml_contents)
.with_context(|| format!("Failed to read `[raze]` settings from {}", root_toml))?;
Ok(data.raze)
}

Expand Down Expand Up @@ -775,7 +771,7 @@ pub fn load_settings(metadata: &Metadata) -> Result<RazeSettings, RazeError> {
result.unwrap()
};

validate_settings(&mut settings, &metadata.workspace_root)?;
validate_settings(&mut settings, metadata.workspace_root.as_ref())?;

Ok(settings)
}
Expand Down
Loading