2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-27 17:43:27 +00:00

fix: fix buildifier 5.0.0 errors (#35)

This commit is contained in:
Derek Cormier 2022-02-11 07:52:01 -08:00 committed by GitHub
parent 2ff9c7154b
commit ca4a9f8c23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 13 deletions

View file

@ -9,7 +9,7 @@ default_stages: [commit]
repos: repos:
# Check formatting and lint for starlark code # Check formatting and lint for starlark code
- repo: https://github.com/keith/pre-commit-buildifier - repo: https://github.com/keith/pre-commit-buildifier
rev: 4.0.1.1 rev: 5.0.0
hooks: hooks:
- id: buildifier - id: buildifier
- id: buildifier-lint - id: buildifier-lint

View file

@ -61,7 +61,7 @@ The runfiles manifest entry path for a file
## to_workspace_path ## to_workspace_path
<pre> <pre>
to_workspace_path(<a href="#to_workspace_path-ctx">ctx</a>, <a href="#to_workspace_path-file">file</a>) to_workspace_path(<a href="#to_workspace_path-file">file</a>)
</pre> </pre>
The workspace relative path for a file The workspace relative path for a file
@ -76,7 +76,6 @@ repository name if the file is from an external repository.
| Name | Description | Default Value | | Name | Description | Default Value |
| :------------- | :------------- | :------------- | | :------------- | :------------- | :------------- |
| <a id="to_workspace_path-ctx"></a>ctx | starlark rule execution context | none |
| <a id="to_workspace_path-file"></a>file | a File object | none | | <a id="to_workspace_path-file"></a>file | a File object | none |
**RETURNS** **RETURNS**

View file

@ -118,7 +118,7 @@ def _output_path(ctx, src):
if src.owner and src.owner.workspace_name and not src.owner.workspace_name in ctx.attr.include_external_repositories: if src.owner and src.owner.workspace_name and not src.owner.workspace_name in ctx.attr.include_external_repositories:
return False return False
result = paths.to_workspace_path(ctx, src) result = paths.to_workspace_path(src)
# strip root paths # strip root paths
root_path = _longest_match(result, ctx.attr.root_paths) root_path = _longest_match(result, ctx.attr.root_paths)

View file

@ -7,7 +7,7 @@
# - ../external_repo/path/to/file # - ../external_repo/path/to/file
# This is converted to the runfiles manifest path of: # This is converted to the runfiles manifest path of:
# - repo/path/to/file # - repo/path/to/file
def _rootpath_to_runfiles_manifest_path(ctx, path, targets): def _rootpath_to_runfiles_manifest_path(ctx, path):
if path.startswith("../"): if path.startswith("../"):
return path[len("../"):] return path[len("../"):]
if path.startswith("./"): if path.startswith("./"):
@ -19,7 +19,7 @@ def _rootpath_to_runfiles_manifest_path(ctx, path, targets):
# - repo/path/to/file # - repo/path/to/file
def _expand_rootpath_to_manifest_path(ctx, input, targets): def _expand_rootpath_to_manifest_path(ctx, input, targets):
paths = ctx.expand_location(input, targets) paths = ctx.expand_location(input, targets)
return " ".join([_rootpath_to_runfiles_manifest_path(ctx, p, targets) for p in paths.split(" ")]) return " ".join([_rootpath_to_runfiles_manifest_path(ctx, p) for p in paths.split(" ")])
def expand_locations(ctx, input, targets = []): def expand_locations(ctx, input, targets = []):
"""Expand location templates. """Expand location templates.

View file

@ -65,7 +65,7 @@ def _to_manifest_path(ctx, file):
else: else:
return ctx.workspace_name + "/" + file.short_path return ctx.workspace_name + "/" + file.short_path
def _to_workspace_path(ctx, file): def _to_workspace_path(file):
"""The workspace relative path for a file """The workspace relative path for a file
This is the full runfiles path of a file excluding its workspace name. This is the full runfiles path of a file excluding its workspace name.
@ -73,7 +73,6 @@ def _to_workspace_path(ctx, file):
repository name if the file is from an external repository. repository name if the file is from an external repository.
Args: Args:
ctx: starlark rule execution context
file: a File object file: a File object
Returns: Returns:

View file

@ -34,7 +34,8 @@ def _propagate_well_known_tags(tags = []):
CPU_PREFIX = "cpu:" CPU_PREFIX = "cpu:"
return [ return [
tag for tag in tags tag
for tag in tags
if tag in WELL_KNOWN_TAGS or tag.startswith(CPU_PREFIX) if tag in WELL_KNOWN_TAGS or tag.startswith(CPU_PREFIX)
] ]

View file

@ -75,7 +75,10 @@ diff_test(
# Load filter from file # Load filter from file
jq( jq(
name = "case_filter_file", name = "case_filter_file",
srcs = ["a.json", "b.json"], srcs = [
"a.json",
"b.json",
],
args = ["--slurp"], args = ["--slurp"],
filter_file = "merge_filter.txt", filter_file = "merge_filter.txt",
) )

View file

@ -124,8 +124,8 @@ def _manifest_path_test_impl(ctx):
def _workspace_path_test_impl(ctx): def _workspace_path_test_impl(ctx):
env = unittest.begin(ctx) env = unittest.begin(ctx)
asserts.equals(env, "LICENSE", paths.to_workspace_path(ctx, ctx.file.f1)) asserts.equals(env, "LICENSE", paths.to_workspace_path(ctx.file.f1))
asserts.equals(env, "lib/paths.bzl", paths.to_workspace_path(ctx, ctx.file.f2)) asserts.equals(env, "lib/paths.bzl", paths.to_workspace_path(ctx.file.f2))
return unittest.end(env) return unittest.end(env)
_ATTRS = { _ATTRS = {

View file

@ -72,7 +72,7 @@ is_external_label_test = unittest.make(
) )
propagate_well_known_tags_test = unittest.make( propagate_well_known_tags_test = unittest.make(
_propagate_well_known_tags_test_impl _propagate_well_known_tags_test_impl,
) )
def utils_test_suite(): def utils_test_suite():