Skip to content

Instantly share code, notes, and snippets.

@hcarvalhoalves
Created November 10, 2020 17:54
Show Gist options
  • Save hcarvalhoalves/089c8878e4007361b82ae9d54e4ad2ee to your computer and use it in GitHub Desktop.
Save hcarvalhoalves/089c8878e4007361b82ae9d54e4ad2ee to your computer and use it in GitHub Desktop.
#!/bin/bash
# Add to project/.git/hooks/ w/ +x permission
echo "Running pre-commit linter..."
files=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(base|clj)$' | tr '\n' ' ' | xargs)
lein do cljfmt fix $files, nsorg -e $files
if [ $? -ne 0 ]; then
echo "Pre-commit failed on staged files. Please check your code and try again."
exit 1 # exit with failure status
fi
git add $files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment