Created
March 21, 2019 14:59
-
-
Save darkhelmet/5d365315c779fcc208275d197eeb22a5 to your computer and use it in GitHub Desktop.
Never commit ruby syntax errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
files() { | |
git diff --name-only --cached --full-index | |
} | |
check() { | |
while read file; do | |
filename=$(basename "$file") | |
extension="${filename##*.}" | |
if [ "rb" = $extension ]; then | |
if [ -f "$file" ]; then ruby -c $file >/dev/null; fi | |
fi | |
done | |
} | |
echo "Checking ruby syntax..." | |
files | check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment