2018-04-11 10:11:35 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Cause the script to exit if a single command fails
|
2018-05-19 16:07:28 -07:00
|
|
|
set -eo pipefail
|
2018-04-11 10:11:35 -07:00
|
|
|
|
2018-05-19 16:07:28 -07:00
|
|
|
# this stops git rev-parse from failing if we run this from the .git directory
|
|
|
|
builtin cd "$(dirname "${BASH_SOURCE:-$0}")"
|
2018-04-11 10:11:35 -07:00
|
|
|
|
2018-05-19 16:07:28 -07:00
|
|
|
ROOT="$(git rev-parse --show-toplevel)"
|
|
|
|
builtin cd "$ROOT"
|
2018-04-11 10:11:35 -07:00
|
|
|
|
2018-05-19 16:07:28 -07:00
|
|
|
yapf \
|
|
|
|
--style "$ROOT/.style.yapf" \
|
|
|
|
--in-place --recursive --parallel \
|
|
|
|
--exclude 'python/ray/cloudpickle' \
|
|
|
|
--exclude 'python/ray/dataframe' \
|
|
|
|
--exclude 'python/ray/rllib' \
|
|
|
|
-- \
|
|
|
|
'test' 'python'
|
2018-04-11 10:11:35 -07:00
|
|
|
|
2018-05-19 16:07:28 -07:00
|
|
|
if ! git diff --quiet; then
|
|
|
|
echo 'Reformatted staged files. Please review and stage the changes.'
|
|
|
|
echo 'Files updated:'
|
|
|
|
echo
|
|
|
|
|
|
|
|
git --no-pager diff --name-only
|
|
|
|
|
|
|
|
exit 1
|
2018-04-11 10:11:35 -07:00
|
|
|
fi
|