diff options
author | John Westcott IV <32551173+john-westcott-iv@users.noreply.github.com> | 2022-03-24 16:39:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 16:39:29 +0100 |
commit | fcdff8bdfb6b041cde04c35453a57b843cfd290f (patch) | |
tree | 93970c4c658674a0ffb70f6162d5cfd6e4b2aec2 /pre-commit.sh | |
parent | Adding ability to run user level pre-commit hooks (#11923) (diff) | |
download | awx-fcdff8bdfb6b041cde04c35453a57b843cfd290f.tar.xz awx-fcdff8bdfb6b041cde04c35453a57b843cfd290f.zip |
Fixing pre-commit.sh for OS X (#11953)
Diffstat (limited to 'pre-commit.sh')
-rwxr-xr-x | pre-commit.sh | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/pre-commit.sh b/pre-commit.sh index c97568dd9d..6c30f1a17c 100755 --- a/pre-commit.sh +++ b/pre-commit.sh @@ -2,8 +2,10 @@ if [ -z $AWX_IGNORE_BLACK ] ; then python_files_changed=$(git diff --cached --name-only --diff-filter=AM | grep -E '\.py') if [ "x$python_files_changed" != "x" ] ; then 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' && \ - exit 1) + if [ $? != 0 ] ; then + 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 @@ -11,12 +13,14 @@ if [ -z $AWX_IGNORE_USER ] ; then FAIL=0 export CHANGED_FILES=$(git diff --cached --name-only --diff-filter=AM) if [ -d ./pre-commit-user ] ; then - for SCRIPT in `find ./pre-commit-user -executable -type f` ; do - echo "Running user pre-commit hook $SCRIPT" - $SCRIPT - if [ $? != 0 ] ; then - echo "User test $SCRIPT failed" - FAIL=1 + for SCRIPT in `find ./pre-commit-user -type f` ; do + if [ -x $SCRIPT ] ; then + echo "Running user pre-commit hook $SCRIPT" + $SCRIPT + if [ $? != 0 ] ; then + echo "User test $SCRIPT failed" + FAIL=1 + fi fi done fi |