rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

pre-commit hook for updating deleted packages removes items added by the script that it calls

Open dougthor42 opened this issue 1 year ago • 0 comments

🐞 bug report

Affected Rule

N/A. This isn't a rule-related bug, but rather a bug with the pre-commit hook update-deleted-packages.

Is this a regression?

No.

Description

Running pre-commit run update-deleted-packages --all-files actually removes items that were added by the script that it calls (./tools/update_deleted_packages)

🔬 Minimal Reproduction

See also https://github.com/bazelbuild/rules_python/pull/1842#issuecomment-2059536521.

  1. Add a new example dir: ./examples/foobar with BUILD.bazel, MODULE.bazel, foo.py files.
  2. run ./tools/update_deleted_packages.sh
  3. Note that examples/foobar is now included in .bazelrc's --deleted_packages arg.
  4. Run pre-commit run update-deleted-packages --all-files

Expected Result:

.bazelrc is unchanged, as it was already updated in (3).

Actual Result:

The examples/foobar value is no longer present in --deleted_packages

🔥 Exception or Error

$ pre-commit run update-deleted-packages --all-files
Update deleted packages..................................................Failed
- hook id: update-deleted-packages
- files were modified by this hook

INFO: Analyzed target @@rules_bazel_integration_test~0.20.0//tools:update_deleted_packages (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target @@rules_bazel_integration_test~0.20.0//tools:update_deleted_packages up-to-date:
  bazel-bin/external/rules_bazel_integration_test~0.20.0/tools/update_deleted_packages
INFO: Elapsed time: 29.376s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/external/rules_bazel_integration_test~0.20.0/tools/update_deleted_packages
dirname: missing operand
Try 'dirname --help' for more information.

🌍 Your Environment

Operating System:

  
$ # Ubuntu 22.04 on WSL(1) on Windows 10.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
  

Output of bazel version:

  
$ bazel version
Bazelisk version: v1.19.0
Build label: 7.0.0
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Dec 11 16:51:49 2023 (1702313509)
Build timestamp: 1702313509
Build timestamp as int: 1702313509
  

Rules_python version:

Dirty working tree off commit cdc7f2f

Anything else relevant?

dougthor42 avatar Apr 17 '24 17:04 dougthor42