Skip to content

Instantly share code, notes, and snippets.

@darkhelmet
Created March 21, 2019 14:59
Show Gist options
  • Save darkhelmet/5d365315c779fcc208275d197eeb22a5 to your computer and use it in GitHub Desktop.
Save darkhelmet/5d365315c779fcc208275d197eeb22a5 to your computer and use it in GitHub Desktop.
Never commit ruby syntax errors
#!/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