Skip to content

Fix typos in crate universe folder #3516

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 1 commit 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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ repos:
- id: buildifier-lint
args: [--version, "v8.2.0", --warnings=all]
- repo: https://github.com/crate-ci/typos
rev: v1.33.1
rev: v1.34.0
hooks:
- id: typos
exclude: |
(?x)^(
crate_universe|
crate_universe/test_data|
examples|
extensions|
ffi|
Expand Down
1 change: 1 addition & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[default.extend-words]
nto = "nto" # For toolchains
flate = "flate" # https://crates.io/crates/flate2
2 changes: 1 addition & 1 deletion crate_universe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ rust_library(
# This target embeds additional, stamping related information (see
# https://docs.bazel.build/versions/main/user-manual.html#workspace_status
# for more information). Set stamp = -1 to indicate that it should respect
# the value of the --stamp comandline flag.
# the value of the --stamp commandline flag.
stamp = -1,
version = VERSION,
visibility = ["//visibility:public"],
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ rust_test(

### Direct Packages

In cases where Rust targets have heavy interractions with other Bazel targests ([Cc][cc], [Proto][proto], etc.),
In cases where Rust targets have heavy interractions with other Bazel targets ([Cc][cc], [Proto][proto], etc.),
maintaining `Cargo.toml` files may have deminishing returns as things like [rust-analyzer][ra] begin to be confused
about missing targets or environment variables defined only in Bazel. In workspaces like this, it may be desirable
to have a "Cargo free" setup. `crates_repository` supports this through the `packages` attribute.
Expand All @@ -124,7 +124,7 @@ crates_repository(
},
# Setting the default package name to `""` forces the use of the macros defined in this repository
# to always use the root package when looking for dependencies or aliases. This should be considered
# optional as the repository also exposes alises for easy access to all dependencies.
# optional as the repository also exposes aliases for easy access to all dependencies.
render_config = render_config(
default_package_name = ""
),
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ _FROM_COMMON_ATTRS = {
"order to prevent other uses of Cargo from impacting having any effect on the generated targets " +
"produced by this rule. For users who either have multiple `crate_repository` definitions in a " +
"WORKSPACE or rapidly re-pin dependencies, setting this to false may improve build times. This " +
"variable is also controled by `CARGO_BAZEL_ISOLATED` environment variable."
"variable is also controlled by `CARGO_BAZEL_ISOLATED` environment variable."
),
default = True,
),
Expand Down Expand Up @@ -1342,7 +1342,7 @@ can be found below where the supported keys for each template can be found in th
default = True,
),
"generate_rules_license_metadata": attr.bool(
doc = "Whether to generate rules license metedata.",
doc = "Whether to generate rules license metadata.",
default = False,
),
"generate_target_compatible_with": attr.bool(
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/private/common_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STDERR ------------------------------------------------------------------------
"""

def execute(repository_ctx, args, env = {}, allow_fail = False, quiet = True):
"""A heler macro for executing some arguments and displaying nicely formatted errors
"""A helper macro for executing some arguments and displaying nicely formatted errors

Args:
repository_ctx (repository_ctx): The rule's context object.
Expand Down Expand Up @@ -159,7 +159,7 @@ def _cargo_home_path(repository_ctx):
return repository_ctx.path(".cargo_home")

def cargo_environ(repository_ctx, isolated = True):
"""Define Cargo environment varables for use with `cargo-bazel`
"""Define Cargo environment variables for use with `cargo-bazel`

Args:
repository_ctx (repository_ctx): The rules context object
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/private/crate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _annotation(
gen_binaries (list or bool, optional): As a list, the subset of the crate's bins that should get `rust_binary`
targets produced. Or `True` to generate all, `False` to generate none.
disable_pipelining (bool, optional): If True, disables pipelining for library targets for this crate.
gen_build_script (bool, optional): An authorative flag to determine whether or not to produce
gen_build_script (bool, optional): An authoritative flag to determine whether or not to produce
`cargo_build_script` targets for the current crate.
patch_args (list, optional): The `patch_args` attribute of a Bazel repository rule. See
[http_archive.patch_args](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_args)
Expand Down
6 changes: 3 additions & 3 deletions crate_universe/private/crates_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index

This will result in all dependencies being updated for a project. The `CARGO_BAZEL_REPIN` environment variable
can also be used to customize how dependencies are updated. The following table shows translations from environment
variable values to the equivilant [cargo update](https://doc.rust-lang.org/cargo/commands/cargo-update.html) command
variable values to the equivalent [cargo update](https://doc.rust-lang.org/cargo/commands/cargo-update.html) command
that is called behind the scenes to update dependencies.

| Value | Cargo command |
Expand Down Expand Up @@ -259,7 +259,7 @@ CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_i
mandatory = True,
),
"compressed_windows_toolchain_names": attr.bool(
doc = "Wether or not the toolchain names of windows toolchains are expected to be in a `compressed` format.",
doc = "Whether or not the toolchain names of windows toolchains are expected to be in a `compressed` format.",
default = True,
),
"generate_binaries": attr.bool(
Expand Down Expand Up @@ -303,7 +303,7 @@ CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_i
"order to prevent other uses of Cargo from impacting having any effect on the generated targets " +
"produced by this rule. For users who either have multiple `crate_repository` definitions in a " +
"WORKSPACE or rapidly re-pin dependencies, setting this to false may improve build times. This " +
"variable is also controled by `CARGO_BAZEL_ISOLATED` environment variable."
"variable is also controlled by `CARGO_BAZEL_ISOLATED` environment variable."
),
default = True,
),
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/private/generate_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def render_config(
keys are [`{triple}`].
regen_command (str, optional): An optional command to demonstrate how generated files should be regenerated.
vendor_mode (str, optional): An optional configuration for rendirng content to be rendered into repositories.
generate_rules_license_metadata (bool, optional): Whether to generate rules license metedata
generate_rules_license_metadata (bool, optional): Whether to generate rules license metadata

Returns:
string: A json encoded struct to match the Rust `config::RenderConfig` struct
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/private/local_crate_mirror.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _local_crate_mirror_impl(repository_ctx):
local_crate_mirror = repository_rule(
doc = """This is a private implementation detail of crate_universe, and should not be relied on in manually written code.

This is effectively a `local_repository` rule impementation, but where the BUILD.bazel file is generated using the `cargo-bazel render` command.""",
This is effectively a `local_repository` rule implementation, but where the `BUILD.bazel` file is generated using the `cargo-bazel render` command.""",
implementation = _local_crate_mirror_impl,
attrs = {
"generator": attr.string(
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/private/splicing_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def compile_splicing_manifest(splicing_config, manifests, cargo_config_path, pac
dict: A dictionary representation of a `cargo_bazel::splicing::SplicingManifest`
"""

# Deserialize information about direct packges
# Deserialize information about direct packages
direct_packages_info = {
# Ensure the data is using kebab-case as that's what `cargo_toml::DependencyDetail` expects.
pkg: kebab_case_keys(dict(json.decode(data)))
Expand All @@ -66,7 +66,7 @@ def compile_splicing_manifest(splicing_config, manifests, cargo_config_path, pac
return splicing_config | splicing_manifest_content

def _no_at_label(label):
"""Strips leading '@'s for stringified labels in the main repository for backwards-comaptibility reasons."""
"""Strips leading '@'s for stringified labels in the main repository for backwards-compatibility reasons."""
s = str(label)
if s.startswith("@@//"):
return s[2:]
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/src/cli/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub fn vendor(opt: VendorOptions) -> anyhow::Result<()> {
&opt.nonhermetic_root_bazel_workspace_dir,
)?;

// Generate renderable contexts for earch package
// Generate renderable contexts for search package
let context = Context::new(annotations, config.rendering.are_sources_present())?;

// Render build files
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub(crate) struct RenderConfig {
}

// Default is manually implemented so that the default values match the default
// values when deserializing, which involves calling the vairous `default_x()`
// values when deserializing, which involves calling the various `default_x()`
// functions specified in `#[serde(default = "default_x")]`.
impl Default for RenderConfig {
fn default() -> Self {
Expand Down Expand Up @@ -240,7 +240,7 @@ pub(crate) struct CrateAnnotations {
/// Which subset of the crate's bins should get produced as `rust_binary` targets.
pub(crate) gen_binaries: Option<GenBinaries>,

/// Determins whether or not Cargo build scripts should be generated for the current package
/// Determines whether or not Cargo build scripts should be generated for the current package
pub(crate) gen_build_script: Option<bool>,

/// Additional data to pass to
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/src/context/platforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ pub(crate) fn resolve_cfg_platforms(
.collect::<Result<BTreeMap<&TargetTriple, &'static TargetInfo>>>()?;

// `cfg-expr` does not understand configurations that are simply platform triples
// (`x86_64-unknown-linux-gnu` vs `cfg(target = "x86_64-unkonwn-linux-gnu")`). So
// (`x86_64-unknown-linux-gnu` vs `cfg(target = "x86_64-unknown-linux-gnu")`). So
// in order to parse configurations, the text is renamed for the check but the
// original is retained for comaptibility with the manifest.
// original is retained for compatibility with the manifest.
let rename = |cfg: &str| -> String { format!("cfg(target = \"{cfg}\")") };
let original_cfgs: BTreeMap<String, String> = configurations
.iter()
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/src/metadata/metadata_annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl LockfileAnnotation {
path.parent()
.context("unexpected empty lockfile path")?,
)
.context("unxpected non-Unicode lockfile path")?;
.context("unexpected non-Unicode lockfile path")?;
if p.starts_with(nonhermetic_root_bazel_workspace_dir) {
// If path in lockfile is under Bazel root, strip Bazel
// root to get the actual path.
Expand Down Expand Up @@ -523,7 +523,7 @@ fn find_workspace_metadata(cargo_metadata: &CargoMetadata) -> Option<WorkspaceMe
}

/// Determines whether or not a package is a workspace member. This follows
/// the Cargo definition of a workspace memeber with one exception where
/// the Cargo definition of a workspace member with one exception where
/// "extra workspace members" are *not* treated as workspace members
fn is_workspace_member(id: &PackageId, cargo_metadata: &CargoMetadata) -> bool {
if cargo_metadata.workspace_members.contains(id) {
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/src/rendering/template_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ impl TemplateEngine {
}
}

/// A convienience wrapper for parsing parameters to tera functions
/// A convenience wrapper for parsing parameters to tera functions
macro_rules! parse_tera_param {
($param:literal, $param_type:ty, $args:ident) => {
match $args.get($param) {
Some(val) => match from_value::<$param_type>(val.clone()) {
Ok(v) => v,
Err(_) => {
return Err(tera::Error::msg(format!(
"The `{}` paramater could not be parsed as a String.",
"The `{}` parameter could not be parsed as a String.",
$param
)))
}
Expand Down
4 changes: 2 additions & 2 deletions crate_universe/src/splicing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl WorkspaceMetadata {
})
.collect();

// It is invald for toml maps to use empty strings as keys. In the case
// It is invalid for toml maps to use empty strings as keys. In the case
// the empty key is expected to be the root package. If the root package
// has a prefix, then all other packages will as well (even if no other
// manifest represents them). The value is then saved as a separate value
Expand Down Expand Up @@ -472,7 +472,7 @@ pub(crate) fn generate_lockfile(

let root_lockfile_path = manifest_dir.join("Cargo.lock");

// Remove the file so it's not overwitten if it happens to be a symlink.
// Remove the file so it's not overwritten if it happens to be a symlink.
if root_lockfile_path.exists() {
fs::remove_file(&root_lockfile_path)?;
}
Expand Down
6 changes: 3 additions & 3 deletions crate_universe/src/splicing/splicer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ const DEFAULT_SPLICING_PACKAGE_VERSION: &str = "0.0.1";

pub(crate) fn default_cargo_package_manifest() -> cargo_toml::Manifest {
// A manifest is generated with a fake workspace member so the [cargo_toml::Manifest::Workspace]
// member is deseralized and is not `None`.
// member is deserialized and is not `None`.
cargo_toml::Manifest::from_str(
&toml::toml! {
[package]
Expand Down Expand Up @@ -536,7 +536,7 @@ pub(crate) fn default_cargo_workspace_manifest(
resolver_version: &cargo_toml::Resolver,
) -> cargo_toml::Manifest {
// A manifest is generated with a fake workspace member so the [cargo_toml::Manifest::Workspace]
// member is deseralized and is not `None`.
// member is deserialized and is not `None`.
let mut manifest = cargo_toml::Manifest::from_str(&textwrap::dedent(&format!(
r#"
[workspace]
Expand Down Expand Up @@ -1379,7 +1379,7 @@ mod test {
)
.unwrap();

// Due to the addition of direct deps for splicing, this package should have been added to the root manfiest.
// Due to the addition of direct deps for splicing, this package should have been added to the root manifest.
assert!(cargo_manifest.package.unwrap().name == DEFAULT_SPLICING_PACKAGE_NAME);
}

Expand Down
4 changes: 2 additions & 2 deletions crate_universe/tools/urls_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ fn calculate_sha256(file_path: &Path) -> String {
let mut hasher = Sha256::new();

loop {
let consummed = {
let consumed = {
let buffer = reader.fill_buf().unwrap();
if buffer.is_empty() {
break;
}
hasher.update(buffer);
buffer.len()
};
reader.consume(consummed);
reader.consume(consumed);
}

let digest = hasher.finalize();
Expand Down