fix: fix buildifier 5.0.0 errors (#35)
This commit is contained in:
parent
2ff9c7154b
commit
ca4a9f8c23
|
@ -9,7 +9,7 @@ default_stages: [commit]
|
|||
repos:
|
||||
# Check formatting and lint for starlark code
|
||||
- repo: https://github.com/keith/pre-commit-buildifier
|
||||
rev: 4.0.1.1
|
||||
rev: 5.0.0
|
||||
hooks:
|
||||
- id: buildifier
|
||||
- id: buildifier-lint
|
||||
|
|
|
@ -61,7 +61,7 @@ The runfiles manifest entry path for a file
|
|||
## to_workspace_path
|
||||
|
||||
<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>
|
||||
|
||||
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 |
|
||||
| :------------- | :------------- | :------------- |
|
||||
| <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 |
|
||||
|
||||
**RETURNS**
|
||||
|
|
|
@ -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:
|
||||
return False
|
||||
|
||||
result = paths.to_workspace_path(ctx, src)
|
||||
result = paths.to_workspace_path(src)
|
||||
|
||||
# strip root paths
|
||||
root_path = _longest_match(result, ctx.attr.root_paths)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# - ../external_repo/path/to/file
|
||||
# This is converted to the runfiles manifest path of:
|
||||
# - repo/path/to/file
|
||||
def _rootpath_to_runfiles_manifest_path(ctx, path, targets):
|
||||
def _rootpath_to_runfiles_manifest_path(ctx, path):
|
||||
if path.startswith("../"):
|
||||
return path[len("../"):]
|
||||
if path.startswith("./"):
|
||||
|
@ -19,7 +19,7 @@ def _rootpath_to_runfiles_manifest_path(ctx, path, targets):
|
|||
# - repo/path/to/file
|
||||
def _expand_rootpath_to_manifest_path(ctx, 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 = []):
|
||||
"""Expand location templates.
|
||||
|
|
|
@ -65,7 +65,7 @@ def _to_manifest_path(ctx, file):
|
|||
else:
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
Args:
|
||||
ctx: starlark rule execution context
|
||||
file: a File object
|
||||
|
||||
Returns:
|
||||
|
|
|
@ -34,7 +34,8 @@ def _propagate_well_known_tags(tags = []):
|
|||
CPU_PREFIX = "cpu:"
|
||||
|
||||
return [
|
||||
tag for tag in tags
|
||||
tag
|
||||
for tag in tags
|
||||
if tag in WELL_KNOWN_TAGS or tag.startswith(CPU_PREFIX)
|
||||
]
|
||||
|
||||
|
|
|
@ -75,7 +75,10 @@ diff_test(
|
|||
# Load filter from file
|
||||
jq(
|
||||
name = "case_filter_file",
|
||||
srcs = ["a.json", "b.json"],
|
||||
srcs = [
|
||||
"a.json",
|
||||
"b.json",
|
||||
],
|
||||
args = ["--slurp"],
|
||||
filter_file = "merge_filter.txt",
|
||||
)
|
||||
|
|
|
@ -124,8 +124,8 @@ def _manifest_path_test_impl(ctx):
|
|||
|
||||
def _workspace_path_test_impl(ctx):
|
||||
env = unittest.begin(ctx)
|
||||
asserts.equals(env, "LICENSE", paths.to_workspace_path(ctx, ctx.file.f1))
|
||||
asserts.equals(env, "lib/paths.bzl", paths.to_workspace_path(ctx, ctx.file.f2))
|
||||
asserts.equals(env, "LICENSE", paths.to_workspace_path(ctx.file.f1))
|
||||
asserts.equals(env, "lib/paths.bzl", paths.to_workspace_path(ctx.file.f2))
|
||||
return unittest.end(env)
|
||||
|
||||
_ATTRS = {
|
||||
|
|
|
@ -72,7 +72,7 @@ is_external_label_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():
|
||||
|
|
Loading…
Reference in New Issue