blob: 404d5fdbf1dc0b03b57a97b5bbd0c2d4d407eeed [file] [log] [blame]
Ravago Jones23dac942022-07-31 16:18:54 -07001#!/bin/bash
2
3# --- begin runfiles.bash initialization v2 ---
4# Copy-pasted from the Bazel Bash runfiles library v2.
5set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
6source "${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
14readonly YAPF="$(rlocation python_yapf/python_yapf)"
15
16# Run everything from the root of the tree.
17cd "${BUILD_WORKSPACE_DIRECTORY}"
18
19# Find all the Python files in the repo.
20python_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.
25if ((${#python_files[@]} > 0)); then
26 exec "${YAPF}" --in-place --parallel --verbose "${python_files[@]}"
27fi