summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rwxr-xr-xpre-commit.sh8
2 files changed, 9 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index e05dd974d2..7f15182dc6 100644
--- a/Makefile
+++ b/Makefile
@@ -272,7 +272,7 @@ black: reports
@(set -o pipefail && $@ $(BLACK_ARGS) awx awxkit awx_collection | tee reports/$@.report)
.git/hooks/pre-commit:
- @echo "[ -z \$$AWX_IGNORE_BLACK ] && (black --check \`git diff --cached --name-only --diff-filter=AM | grep -E '\.py$\'\` || (echo 'To fix this, run \`make black\` to auto-format your code prior to commit, or set AWX_IGNORE_BLACK=1' && exit 1))" > .git/hooks/pre-commit
+ @echo "./pre-commit.sh" > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
genschema: reports
diff --git a/pre-commit.sh b/pre-commit.sh
new file mode 100755
index 0000000000..24393c790b
--- /dev/null
+++ b/pre-commit.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/bash
+
+if [ -z $AWX_IGNORE_BLACK ]
+then
+ black --check $(git diff --cached --name-only --diff-filter=AM | grep -E '\.py') || \
+ (echo 'To fix this, run `make black` to auto-format your code prior to commit, or set AWX_IGNORE_BLACK=1' && \
+ exit 1)
+fi