summaryrefslogtreecommitdiffstats
path: root/pre-commit.sh
diff options
context:
space:
mode:
authorJohn Westcott IV <32551173+john-westcott-iv@users.noreply.github.com>2022-03-24 15:58:14 +0100
committerGitHub <noreply@github.com>2022-03-24 15:58:14 +0100
commitb9cdd6f2c82ad2ddbb7b49e053abb1aee11af745 (patch)
treecbfffc9229529f378984bd93cd3def320d73ae4a /pre-commit.sh
parentMerge pull request #11941 from shanemcd/update-devel-image-refs (diff)
downloadawx-b9cdd6f2c82ad2ddbb7b49e053abb1aee11af745.tar.xz
awx-b9cdd6f2c82ad2ddbb7b49e053abb1aee11af745.zip
Adding ability to run user level pre-commit hooks (#11923)
* Adding ability to run user level pre-commit hooks * Adding pre-commit docs in CONTRIBUTING.md
Diffstat (limited to 'pre-commit.sh')
-rwxr-xr-xpre-commit.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/pre-commit.sh b/pre-commit.sh
index 80a49fb47c..c97568dd9d 100755
--- a/pre-commit.sh
+++ b/pre-commit.sh
@@ -6,3 +6,22 @@ if [ -z $AWX_IGNORE_BLACK ] ; then
exit 1)
fi
fi
+
+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
+ fi
+ done
+ fi
+ if [ $FAIL == 1 ] ; then
+ echo "One or more user tests failed, see messages above"
+ exit 1
+ fi
+fi