Skip to content

Commit d160f27

Browse files
committed
precommit: terraform fmt makes changes on disk
### 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.
1 parent 4d2be56 commit d160f27

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

hooks/terraform-fmt.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export PATH=$PATH:/usr/local/bin
1212
FMT_ERROR=0
1313

1414
for file in "$@"; do
15-
terraform fmt -diff -check "$file" || FMT_ERROR=$?
15+
terraform fmt "$file" || FMT_ERROR=$?
1616
done
1717

1818
# reset path to the original value

memfault-patch.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
sed -i -e 's/terraform fmt -diff -check/terraform fmt/' hooks/terraform-fmt.sh

0 commit comments

Comments
 (0)