-
Notifications
You must be signed in to change notification settings - Fork 104
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
Add SHA-256 to the local_repositories #47
Conversation
This is good practice to have them and we get them for free from Cargo.
The previous one doesn't build on my platform.
The update to cargo.lock is actually addressing the problem we see in Travis at HEAD. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks great! Thanks for fixing the broken master and cleaning up those warnings as well.
@@ -10,7 +10,10 @@ def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(): | |||
name = "{{workspace.gen_workspace_prefix}}__{{crate.pkg_name | slugify | replace(from="-", to="_")}}__{{crate.pkg_version | slugify | replace(from="-", to="_")}}", | |||
url = "https://crates-io.s3-us-west-1.amazonaws.com/crates/{{crate.pkg_name}}/{{crate.pkg_name}}-{{crate.pkg_version}}.crate", | |||
type = "tar.gz", | |||
strip_prefix = "{{crate.pkg_name}}-{{crate.pkg_version}}", | |||
{% if crate.sha256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use "{%-" to accomplish the same thing as you're accomplishing by splitting the tag.
Example: https://github.com/google/cargo-raze/blob/master/impl/src/templates/crate.BUILD.template#L23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer. Done!
impl/src/metadata.rs
Outdated
@@ -272,6 +273,9 @@ impl<'config> MetadataFetcher for CargoInternalsMetadataFetcher<'config> { | |||
features.insert(feature.clone(), features_or_dependencies.clone()); | |||
} | |||
|
|||
// Cargo use SHA256 for checksum so we can use them directly | |||
let sha256 = package.manifest().summary().checksum().and_then(|x| Some(x.to_string())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two Nits:
s/and_then(|x| Some(x.to_string()))
/map(ToString::to_string)
The and_then
is only necessary when the mapping function yields an option. map
is similar but without the option. ToString::to_string
is the direct reference to the method (though |x| x.to_string()
is totally fine as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
PTAL. Thanks for the review! |
This PR needs a followup. Not usre how I missed this in review, but you added a field into a struct that I technically don't control the definition of -- Metadata.{...} is controlled by cargo as it's what they emit from SerializedPackage: When I throw the switch to use |
The SHA-256 is available from Cargo so it's easy to expose and it helps Bazel with caching and reproducibility.
This PR also contains 2 minor fixes: