From 1472749da80c051e1850bc63026ee5c1918211df Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 7 Mar 2024 13:43:07 +1100 Subject: [PATCH] Add dev script to run rubocop on changed files --- script/rubocop-diff.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 script/rubocop-diff.sh diff --git a/script/rubocop-diff.sh b/script/rubocop-diff.sh new file mode 100755 index 0000000000..32dbef1ca8 --- /dev/null +++ b/script/rubocop-diff.sh @@ -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