Skip to content

Instantly share code, notes, and snippets.

@blindsey
Last active July 20, 2017 14:20
Show Gist options
  • Save blindsey/5490920 to your computer and use it in GitHub Desktop.
Save blindsey/5490920 to your computer and use it in GitHub Desktop.
git pre-commit hook for puppet-lint
#!/bin/bash
EXEC=/usr/bin/puppet-lint
if [ -x $EXEC ]; then
git status -s | grep -v ^D | grep '.pp$' | awk '{print $2}' | xargs $EXEC --with-filename
if [ $? -ne 0 ]; then
echo -e "\033[38;5;148m!! Commit rejected due to puppet-lint ERROR !!\033[0m"
exit 1
fi
fi
exit 0
@blindsey
Copy link
Author

  1. gem install puppet-lint
  2. Copy this script into .git/hooks/pre-commit and make it executable
  3. Profit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment