Skip to content

Commit a1415f2

Browse files
committed
Updated pre-commit hook
1 parent 55e13e2 commit a1415f2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.git_hooks/pre-commit

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/bin/sh
22

33
# Get a list of the staged files
4-
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
4+
STAGED_RUBY_FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | grep ".rb")
55

6-
# If the files list is empty exit
7-
[ -z "$FILES" ] && exit 0
6+
# If ruby_files string is non-zero
7+
if [ ! -z $STAGED_RUBY_FILES ]
8+
then
9+
echo "[Pre commit hook] Running standardrb linting"
810

9-
echo "[Pre commit hook] Running standardrb linting"
10-
11-
docker compose run --rm --no-deps -T web standardrb $FILES
11+
# 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

Comments
 (0)