summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/git-pre-commit-hook13
-rwxr-xr-xbin/style-check2
2 files changed, 6 insertions, 9 deletions
diff --git a/bin/git-pre-commit-hook b/bin/git-pre-commit-hook
index 2a65775a..81ace2cd 100755
--- a/bin/git-pre-commit-hook
+++ b/bin/git-pre-commit-hook
@@ -9,14 +9,9 @@
cd $(dirname "$0")/../..
-IFS=$'\n'
-files=( $(git diff-index --cached --name-only --diff-filter=AMCR HEAD) )
+errors=$(git diff --cached | bin/style-check --diff 2>&1)
-if [ "${#files}" -gt 0 ]; then
- errors=$(bin/style-check "${files[@]}" 2>&1)
-
- if [ "$?" != "0" ]; then
- echo "$errors"
- exit 1
- fi
+if [ "$?" != "0" ]; then
+ echo "$errors"
+ exit 1
fi
diff --git a/bin/style-check b/bin/style-check
index ead4d553..bafd6e74 100755
--- a/bin/style-check
+++ b/bin/style-check
@@ -2,5 +2,7 @@
# Checks Python coding style based on our project's preferences. Checks the
# files passed on the command-line or everything if no files are passed.
+# Instead of files, "--diff" may be passed to check only the lines changed
+# by a diff piped to standard input.
flake8 --count --max-complexity=10 --max-line-length=150 --statistics --exclude=pyembroidery,__init__.py,electron,build,src,dist "${@:-.}"