mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-17 00:07:24 +00:00
Add dev script to run rubocop on changed files
This commit is contained in:
23
script/rubocop-diff.sh
Executable file
23
script/rubocop-diff.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# While you are developing, you can call this script to check all
|
||||
# changed files. And then you can also tell Git to check before every
|
||||
# commit by adding this line to your `.git/hooks/pre-commit` file:
|
||||
#
|
||||
# ./script/rubocop-diff.sh --cached || exit 1
|
||||
#
|
||||
|
||||
rubocop="`dirname $0`/../bin/rubocop"
|
||||
cached="$1" # may be empty
|
||||
|
||||
if git diff $cached --diff-filter=ACMR HEAD --quiet; then
|
||||
# nothing changed
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exec git diff $cached --name-only --relative --diff-filter=ACMR HEAD |\
|
||||
xargs \
|
||||
$rubocop --force-exclusion \
|
||||
--fail-level A \
|
||||
--format simple \
|
||||
--parallel --cache true
|
||||
Reference in New Issue
Block a user