We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 55e13e2 commit a1415f2Copy full SHA for a1415f2
.git_hooks/pre-commit
@@ -1,11 +1,13 @@
1
#!/bin/sh
2
3
# Get a list of the staged files
4
-FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
+STAGED_RUBY_FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | grep ".rb")
5
6
-# If the files list is empty exit
7
-[ -z "$FILES" ] && exit 0
+# If ruby_files string is non-zero
+if [ ! -z $STAGED_RUBY_FILES ]
8
+then
9
+ echo "[Pre commit hook] Running standardrb linting"
10
-echo "[Pre commit hook] Running standardrb linting"
-
11
-docker compose run --rm --no-deps -T web standardrb $FILES
+ # If standardrb returns a non 0 response, exit
12
+ docker compose run --rm --no-deps -T web standardrb $STAGED_RUBY_FILES || exit 1
13
+fi
0 commit comments