Skip to content

Commit 985d1d4

Browse files
authored
precommit: terraform fmt makes changes on disk (#1)
### Issues Addressed Most of our pre-commit checks just make the changes that are rote, obvious changes. Not `terraform fmt`! Instead, it just reports the error and exits, meaning you have to fix the issue manually. 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.
2 parents 4d2be56 + d160f27 commit 985d1d4

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)