Fixing pre-commit.sh for OS X (#11953)

This commit is contained in:
John Westcott IV 2022-03-24 11:39:29 -04:00 committed by GitHub
parent b9cdd6f2c8
commit fcdff8bdfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,8 +2,10 @@ if [ -z $AWX_IGNORE_BLACK ] ; then
python_files_changed=$(git diff --cached --name-only --diff-filter=AM | grep -E '\.py') python_files_changed=$(git diff --cached --name-only --diff-filter=AM | grep -E '\.py')
if [ "x$python_files_changed" != "x" ] ; then if [ "x$python_files_changed" != "x" ] ; then
black --check $python_files_changed || \ black --check $python_files_changed || \
(echo 'To fix this, run `make black` to auto-format your code prior to commit, or set AWX_IGNORE_BLACK=1' && \ if [ $? != 0 ] ; then
exit 1) echo 'To fix this, run `make black` to auto-format your code prior to commit, or set AWX_IGNORE_BLACK=1'
exit 1
fi
fi fi
fi fi
@ -11,13 +13,15 @@ if [ -z $AWX_IGNORE_USER ] ; then
FAIL=0 FAIL=0
export CHANGED_FILES=$(git diff --cached --name-only --diff-filter=AM) export CHANGED_FILES=$(git diff --cached --name-only --diff-filter=AM)
if [ -d ./pre-commit-user ] ; then if [ -d ./pre-commit-user ] ; then
for SCRIPT in `find ./pre-commit-user -executable -type f` ; do for SCRIPT in `find ./pre-commit-user -type f` ; do
if [ -x $SCRIPT ] ; then
echo "Running user pre-commit hook $SCRIPT" echo "Running user pre-commit hook $SCRIPT"
$SCRIPT $SCRIPT
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
echo "User test $SCRIPT failed" echo "User test $SCRIPT failed"
FAIL=1 FAIL=1
fi fi
fi
done done
fi fi
if [ $FAIL == 1 ] ; then if [ $FAIL == 1 ] ; then