Ravago Jones | 23dac94 | 2022-07-31 16:18:54 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # --- begin runfiles.bash initialization v2 --- |
| 4 | # Copy-pasted from the Bazel Bash runfiles library v2. |
| 5 | set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash |
| 6 | source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ |
| 7 | source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ |
| 8 | source "$0.runfiles/$f" 2>/dev/null || \ |
| 9 | source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 10 | source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 11 | { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e |
| 12 | # --- end runfiles.bash initialization v2 --- |
| 13 | |
| 14 | readonly YAPF="$(rlocation python_yapf/python_yapf)" |
| 15 | |
| 16 | # Run everything from the root of the tree. |
| 17 | cd "${BUILD_WORKSPACE_DIRECTORY}" |
| 18 | |
| 19 | # Find all the Python files in the repo. |
| 20 | python_files=($(git ls-tree --name-only --full-tree -r @ \ |
| 21 | | grep -v '^third_party/' \ |
| 22 | | (grep '\.py$' || :))) |
| 23 | |
| 24 | # If we have any Python files, format them. |
| 25 | if ((${#python_files[@]} > 0)); then |
| 26 | exec "${YAPF}" --in-place --parallel --verbose "${python_files[@]}" |
| 27 | fi |