Skip to content

Instantly share code, notes, and snippets.

@myanch200
myanch200 / pre-commit
Last active May 13, 2023 21:51 — forked from edisonywh/pre-commit
Run Rubocop in Git's pre-commit hook
```
#!/bin/sh
echo "\nRunning rubocop 🚓 💨 💨 💨\n"
declare -a ERRORS=()
for file in $(git diff --cached --name-only | grep -E '\.rb$')
do
ERRORS+=("$(rubocop $file | grep -e 'C:' -e 'E:')")
done