Created
March 10, 2019 21:30
-
-
Save felixhummel/bf2026ee1af91fb1662b710c58a68062 to your computer and use it in GitHub Desktop.
terraform pre-commit hook to format staged .tf files
This file contains hidden or 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
#!/bin/bash | |
# License: WTFPL | |
set -euo pipefail | |
# "--diff-filter d" excludes deleted files from this list | |
files=$(git diff --cached --diff-filter d --name-only -- "*.tf") | |
for f in $files; do | |
terraform fmt "$f" | |
git add "$f" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment