From 7758f2c089b64262275bf47c52930f8877e70f4f Mon Sep 17 00:00:00 2001 From: Markus Hofbauer Date: Mon, 20 Jan 2025 23:04:41 +0100 Subject: [PATCH] Add pre-commit hooks to format trailing whitespaces (#924) --- .pre-commit-config.yaml | 12 ++++++ CHANGELOG.md | 50 ++++++++++++------------- doc_build/merge.py | 2 +- docs/0.10.0/reference.md | 29 +++++++------- docs/0.6.0/reference.md | 26 ++++++------- docs/0.7.0/reference.md | 27 ++++++------- docs/0.8.0/reference.md | 27 ++++++------- docs/0.9.1/reference.md | 27 ++++++------- docs/1.0.1/reference.md | 3 -- docs/_config.yml | 2 +- docs/latest.md | 3 -- docs/pkg_deb.md | 2 - examples/naming_package_files/readme.md | 1 - examples/rich_structure/docs/index.md | 1 - examples/time_stamping/readme.md | 2 +- pkg/.bazelignore | 2 +- pkg/mappings.bzl | 24 ++++++------ pkg/private/build_info.py | 2 +- pkg/private/tar/tar_writer.py | 3 +- tests/rpm/rpm_util.py | 4 +- 20 files changed, 118 insertions(+), 131 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19111811..1ce1a778 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,18 @@ repos: hooks: - id: buildifier - id: buildifier-lint + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-toml + - id: destroyed-symlinks + - id: detect-private-key + - id: end-of-file-fixer + exclude: | + (?x)^( + tests/testdata/ + ) + - id: trailing-whitespace - repo: https://github.com/crate-ci/typos rev: v1.29.4 hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index d4e24cd3..9c1f94de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,7 @@ Thanks to: Alex Bozhenko, Chuck Grindel, Diego Ortin, and Tomasz Wojno **Breaking Changes - Remove PackageArtifactsInfo. (#752) - + Thanks to: Adam Azarchs, Alex Eagle, August Karlstedt, Austin Schuh, Adrian Vogelsgesang, flode, Florian Scheibner, Ignas Kaziukėnas, Jean-Hadrien Chabran, Matt, Mike Kelly, Paul Draper, Sam Schwebach, Tomasz Wojno, and Vertexwahn @@ -117,7 +117,7 @@ for contributions to this release. - Get rid of the long deprecated archive_name and extension from pkg_zip. (#552) - Make 'out' work in a reasonable way. Fixes #414 - Partial fix for #284 - + ## Bug fixes: - Only allow .deb Description to be multiline. (#573) @@ -533,11 +533,11 @@ commit 48001d12e7037b04dc5b28fadfb1e10a8447e2fc Date: Thu Mar 12 15:14:32 2020 -0400 Depend on rules_python (#140) - + * load rules python - + * add workspace deps - + * add missing loads commit 2b375a08bfe36d2c35885a6f4e5b12d7898c9426 @@ -545,11 +545,11 @@ commit 2b375a08bfe36d2c35885a6f4e5b12d7898c9426 Date: Wed Mar 11 14:49:21 2020 -0400 Update test data in response to #121 (#137) - + PR #121 changed pkg_deb's behavior but didn't update test data to match. - + Reported in PR #132. - + Testing Done: - `bazelisk test ...` @@ -558,29 +558,29 @@ commit e5919f43791b2d4c5ab9e68786087cf889b9987e Date: Fri Feb 28 01:22:37 2020 -0500 Add pkgfilegroup for package-independent destination mappings (#128) - + * Add pkgfilegroup for package-independent destination mappings - + This adds an experimental rule, `pkgfilegroup`, along with associated Providers, that gives rule developers and users a consistent mechanism for using the output of bazel targets in packaging rules. - + Inspired by #36. - + Other capabilities that are provided by this that were not mentioned in #36 are: - + - Creation of empty directories (`pkg_mkdirs`) - Exclusion of files from a `pkgfilegroup` (`excludes`) - Renames of files in a `pkgfilegroup` (`renames`) - + * Add analysis tests for pkgfilegroup and friends - + This provides some analysis tests for various features of `pkgfilegroup` and `pkg_mkdirs`. See #128. - + You can run them by invoking `bazel test experimental/...` from the `pkg` directory - + This implementation of pkgfilegroup was inspired by #36. commit 7a991dea418ab17c7e86f0a7b5e7d4a87ef4304b @@ -588,15 +588,15 @@ commit 7a991dea418ab17c7e86f0a7b5e7d4a87ef4304b Date: Fri Feb 28 01:02:24 2020 -0500 Improve handling of sources from external repositories (#132) - + Avoid use of [`File.short_path`][1] when mapping filenames, because when creating archives from files imported from external repositories we'll create archive members with leading `./../` prefixes. Instead, we'll stick to stripping to leading `File.root.path` (if present) from `File.path`, resulting in archive members like `external/repo/package/file.txt`. - + [1]: https://docs.bazel.build/versions/master/skylark/lib/File.html#short_path - + Resolves #131. commit 532f2857e712c5fcb71c662d680108685b242251 @@ -610,7 +610,7 @@ commit 5877fa85b8598b5bb2186d3addca2408b1e61c5e Date: Fri Feb 28 05:49:40 2020 +0000 Rpm source date epoch (#113) - + * Added --source_date_epoch * Support source_date_epoch_file since stamp variables are not accessible * Fixed _make_rpm label @@ -628,9 +628,9 @@ commit 2f5c9815a7bde4f18acfde268bd63fedd107d87c Date: Wed Dec 4 22:32:01 2019 +0100 Add "./" prefix to files in control.tar (#121) - + This improves compatibility to Debian packages created using dpkg. - + https://github.com/bazelbuild/rules_pkg/issues/116 commit 2f09779667f0d6644c2ca5914d6113a82666ec63 @@ -638,7 +638,7 @@ commit 2f09779667f0d6644c2ca5914d6113a82666ec63 Date: Fri Nov 15 10:09:45 2019 -0800 pkg_deb: Support Breaks and Replaces. (#117) - + https://www.debian.org/doc/debian-policy/ch-relationships.html#overwriting-files-and-replacing-packages-replaces commit 9192d3b3a0f6ccfdecdc66f08f0b2664fa0afc0f @@ -646,7 +646,7 @@ commit 9192d3b3a0f6ccfdecdc66f08f0b2664fa0afc0f Date: Fri Oct 4 16:33:47 2019 -0400 Fix repo names with '-' in them. - + We can not use the form "@repo-name" in Bazel, so the common solution is to transform that to "@repo_name". We auto-correct the repo names to the required form when printing the WORKSPACE stanza. diff --git a/doc_build/merge.py b/doc_build/merge.py index ae67d10d..9ff78421 100755 --- a/doc_build/merge.py +++ b/doc_build/merge.py @@ -75,7 +75,7 @@ def fix_stardoc_table_align(line: str) -> str: def main(argv: typing.Sequence[str]) -> None: wrapper_map = {} - for file in argv[1:]: + for file in argv[1:]: merge_file(file, sys.stdout, wrapper_map) if wrapper_map: print("We didn't use all the @wraps()", wrapper_map, file=sys.stderr) diff --git a/docs/0.10.0/reference.md b/docs/0.10.0/reference.md index 59393635..c52c1e02 100755 --- a/docs/0.10.0/reference.md +++ b/docs/0.10.0/reference.md @@ -109,7 +109,7 @@ pkg_deb(name, archit - `out` the Debian package or a symlink to the actual package. - `deb` the package with any precise file name created with `package_file_name`. - `changes` the .changes file. - + **ATTRIBUTES** @@ -225,7 +225,7 @@ Creates an RPM format package via `pkg_filegroup` and friends. - `out` the RPM or a symlink to the actual package. - `rpm` the package with any precise file name created with `package_file_name`. - `changes` the .changes file. - + **ATTRIBUTES** @@ -396,14 +396,14 @@ filter_directory(name, spec_file | - | Label | required | | | version | - | String | optional | "" | | version_file | - | Label | optional | None | - - - diff --git a/docs/0.6.0/reference.md b/docs/0.6.0/reference.md index 8a8b5f9f..54954232 100755 --- a/docs/0.6.0/reference.md +++ b/docs/0.6.0/reference.md @@ -221,7 +221,7 @@ Creates an RPM format package via `pkg_filegroup` and friends. Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -426,14 +426,14 @@ filter_directory(name, spec_file | - | Label | required | | | version | - | String | optional | "" | | version_file | - | Label | optional | None | - - diff --git a/docs/0.7.0/reference.md b/docs/0.7.0/reference.md index bc673455..48393c60 100755 --- a/docs/0.7.0/reference.md +++ b/docs/0.7.0/reference.md @@ -199,7 +199,7 @@ Creates an RPM format package via `pkg_filegroup` and friends. Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -360,14 +360,14 @@ filter_directory(name, spec_file | - | Label | required | | | version | - | String | optional | "" | | version_file | - | Label | optional | None | - - - diff --git a/docs/0.8.0/reference.md b/docs/0.8.0/reference.md index 4ba55cc2..187dba7e 100755 --- a/docs/0.8.0/reference.md +++ b/docs/0.8.0/reference.md @@ -203,7 +203,7 @@ Creates an RPM format package via `pkg_filegroup` and friends. Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -364,14 +364,14 @@ filter_directory(name, spec_file | - | Label | required | | | version | - | String | optional | "" | | version_file | - | Label | optional | None | - - - diff --git a/docs/0.9.1/reference.md b/docs/0.9.1/reference.md index 52293be0..0914931f 100755 --- a/docs/0.9.1/reference.md +++ b/docs/0.9.1/reference.md @@ -204,7 +204,7 @@ Creates an RPM format package via `pkg_filegroup` and friends. Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -365,14 +365,14 @@ filter_directory(name, spec_file | - | Label | required | | | version | - | String | optional | "" | | version_file | - | Label | optional | None | - - - diff --git a/docs/1.0.1/reference.md b/docs/1.0.1/reference.md index e6eb916f..ea293dd9 100755 --- a/docs/1.0.1/reference.md +++ b/docs/1.0.1/reference.md @@ -765,6 +765,3 @@ Legacy version | spec_file | - | Label | required | | | version | - | String | optional | `""` | | version_file | - | Label | optional | `None` | - - - diff --git a/docs/_config.yml b/docs/_config.yml index c4192631..277f1f2c 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-cayman \ No newline at end of file +theme: jekyll-theme-cayman diff --git a/docs/latest.md b/docs/latest.md index d2fb47f1..167c7212 100755 --- a/docs/latest.md +++ b/docs/latest.md @@ -765,6 +765,3 @@ Legacy version | spec_file | - | Label | required | | | version | - | String | optional | `""` | | version_file | - | Label | optional | `None` | - - - diff --git a/docs/pkg_deb.md b/docs/pkg_deb.md index 6e7faa1b..4fe1566f 100755 --- a/docs/pkg_deb.md +++ b/docs/pkg_deb.md @@ -79,5 +79,3 @@ Creates a deb file. See pkg_deb_impl. | name |

-

| none | | archive_name |

-

| None | | kwargs |

-

| none | - - diff --git a/examples/naming_package_files/readme.md b/examples/naming_package_files/readme.md index 8e362721..7d6da587 100644 --- a/examples/naming_package_files/readme.md +++ b/examples/naming_package_files/readme.md @@ -104,4 +104,3 @@ $ ls -l bazel-bin/a_deb_package.deb bazel-bin/foo-tools_1-2_k8.deb lrwxrwxrwx 1 user primarygroup 163 Jul 26 12:56 bazel-bin/a_deb_package.deb -> /home/user/.cache/bazel/_bazel_user/.../execroot/rules_pkg_examples/bazel-out/k8-fastbuild/bin/foo-tools_1-2_k8.deb -r-xr-xr-x 1 user primarygroup 10662 Jul 26 12:56 bazel-bin/foo-tools_1-2_k8.deb ``` - diff --git a/examples/rich_structure/docs/index.md b/examples/rich_structure/docs/index.md index 29e7b82a..dbfbf919 100644 --- a/examples/rich_structure/docs/index.md +++ b/examples/rich_structure/docs/index.md @@ -1,4 +1,3 @@ # The foo system Some text - diff --git a/examples/time_stamping/readme.md b/examples/time_stamping/readme.md index 39d2edff..2903395c 100644 --- a/examples/time_stamping/readme.md +++ b/examples/time_stamping/readme.md @@ -13,7 +13,7 @@ Read the BUILD file for more details. ## Try this ``` -bazel build :* +bazel build :* for tarball in bazel-bin/*.tar ; do echo ==== $tarball tar tvf $tarball diff --git a/pkg/.bazelignore b/pkg/.bazelignore index b856cd9b..b05fe20e 100644 --- a/pkg/.bazelignore +++ b/pkg/.bazelignore @@ -1 +1 @@ -tests/external_project \ No newline at end of file +tests/external_project diff --git a/pkg/mappings.bzl b/pkg/mappings.bzl index be863ece..789c00fa 100644 --- a/pkg/mappings.bzl +++ b/pkg/mappings.bzl @@ -441,7 +441,7 @@ pkg_files = rule( will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the `prefix` and `strip_prefix` attributes), not the directory name. - + The following keys are rejected: - Any label that expands to more than one file (mappings must be @@ -449,13 +449,13 @@ pkg_files = rule( - Any label or file that was either not provided or explicitly `exclude`d. - + The following values result in undefined behavior: - "" (the empty string) - "." - + - Anything containing ".." """, @@ -808,14 +808,14 @@ filter_directory = rule( doc = """Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. Effective order of operations: - + 1) Files are `exclude`d 2) `renames` _or_ `strip_prefix` is applied. - 3) `prefix` is applied - + 3) `prefix` is applied + In particular, if a `rename` applies to an individual file, `strip_prefix` will not be applied to that particular file. - + Each non-`rename``d path will look like this: ``` @@ -823,11 +823,11 @@ filter_directory = rule( ``` Each `rename`d path will look like this: - + ``` $OUTPUT_DIR/$PREFIX/$FILE_RENAMED ``` - + If an operation cannot be applied (`strip_prefix`) to any component in the directory, or if one is unused (`exclude`, `rename`), the underlying command will fail. See the individual attributes for details. @@ -858,11 +858,11 @@ filter_directory = rule( ), "renames": attr.string_dict( doc = """Files to rename in the output directory. - + Keys are destinations, values are sources prior to any path modifications (e.g. via `prefix` or `strip_prefix`). Files that are `exclude`d must not be renamed. - + This currently only operates on individual files. `strip_prefix` does not apply to them. @@ -871,7 +871,7 @@ filter_directory = rule( ), "excludes": attr.string_list( doc = """Files to exclude from the output directory. - + Each element must refer to an individual file in `src`. All exclusions must be used. diff --git a/pkg/private/build_info.py b/pkg/private/build_info.py index 6780623e..8b8f3a03 100644 --- a/pkg/private/build_info.py +++ b/pkg/private/build_info.py @@ -20,7 +20,7 @@ def get_timestamp(volatile_status_file): Reads a file of "namevalue" pairs and returns the value of the BUILD_TIMESTAMP. The file should be in the workspace status format: https://docs.bazel.build/versions/master/user-manual.html#workspace_status - + Args: volatile_status_file: path to input file. Typically ctx.version_file.path. Returns: diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py index 6682366f..4495e5c0 100644 --- a/pkg/private/tar/tar_writer.py +++ b/pkg/private/tar/tar_writer.py @@ -102,7 +102,7 @@ def __init__(self, self.name = name self.tar = tarfile.open(name=name, mode=mode, fileobj=self.fileobj, - format=tarfile.GNU_FORMAT) + format=tarfile.GNU_FORMAT) self.members = set() self.directories = set() # Preseed the added directory list with things we should not add. If we @@ -344,4 +344,3 @@ def close(self): if self.compressor_proc and self.compressor_proc.wait() != 0: raise self.Error('Custom compression command ' '"{}" failed'.format(self.compressor_cmd)) - diff --git a/tests/rpm/rpm_util.py b/tests/rpm/rpm_util.py index 5655fc54..fe27ad38 100644 --- a/tests/rpm/rpm_util.py +++ b/tests/rpm/rpm_util.py @@ -66,8 +66,8 @@ def read_rpm_filedata(rpm_file_path, rpm_bin_path="rpm", query_tag_map=None): - FILENAMES -> path (file absolute path) - FILEDIGESTS -> digest (hash of file. MD5 for compatibility) - - FILEUSERNAME -> user (UNIX owning user) - - FILEGROUPNAME -> group (UNIX owning group) + - FILEUSERNAME -> user (UNIX owning user) + - FILEGROUPNAME -> group (UNIX owning group) - FILEMODES:octal -> mode (UNIX mode, as an octal string) - FILEFLAGS:fflags -> fflags (RPM file flags as a string, see upstream documentation) - FILELINKTOS -> Symlink target, or nothing (something "falsy") if not provided