Skip to content

Commit

Permalink
precommit: terraform fmt makes changes on disk
Browse files Browse the repository at this point in the history
 ### Issues Addressed
Most of our pre-commit checks just make the changes that are rote,
obvious changes. Not `terraform fmt`! And there's no reason for it, it's
just someone decided to do it that way and the maintainers won't switch
it back. Comment thread:
gruntwork-io#48

 ### Summary of Changes
I patched precommit to use the expected behavior. I included a shell
file to add the patch so it's easy to stay up-to-date with upstream.

 ### Test Plan
- Tested that precommit now automatically updates terraform files when
  using this branch for precommit.
  • Loading branch information
topher200 committed Jan 27, 2022
1 parent 4d2be56 commit d160f27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hooks/terraform-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export PATH=$PATH:/usr/local/bin
FMT_ERROR=0

for file in "$@"; do
terraform fmt -diff -check "$file" || FMT_ERROR=$?
terraform fmt "$file" || FMT_ERROR=$?
done

# reset path to the original value
Expand Down
3 changes: 3 additions & 0 deletions memfault-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sed -i -e 's/terraform fmt -diff -check/terraform fmt/' hooks/terraform-fmt.sh

0 comments on commit d160f27

Please sign in to comment.