Uh oh!
There was an error while loading. Please reload this page.
terraform-fmt updates files, optionally skipped via flags - #53
Conversation
| for file in "$@"; do | ||
| terraform fmt -diff -check "$file" || FMT_ERROR=$? | ||
| for file in "$FILES"; do | ||
| file=$(dirname "$file") |
There was a problem hiding this comment.
This is required to be able to run the hook outside the repo folder. For example, pre-commit try-repo /path/to/local/hook terraform-fmt would invoke terraform fmt with files relative to that /path/to/local/hook. By providing the entire dirname, we can use the pre-commit tool for local development easily.
tyron
commented
Aug 15, 2021
@brikis98 , @yorinasub17 please let me know if this is OK to be reviewed, or if you'd prefer that we don't revert the default behaviour -- rather just expose the flag to switch to the old one. |
| write_changes=true | ||
| FILES=() | ||
| parse_arguments() { |
There was a problem hiding this comment.
Inspired on shellcheck.sh's version:
pre-commit/hooks/shellcheck.sh
Line 13 in e9250bd
joshmyers
commented
Feb 10, 2022
Any movement on this? Seems a few folks would like old behavior |
mleuthold
commented
Feb 11, 2022
Just my 2cents: I thought with 1.1.17 this would have been fixed by now. Because it is not, I will still continue using 0.1.11 for auto format files. |
ysawa0
commented
Mar 22, 2022
+1 on this change. Printing the diff is not as useful as auto-correcting the styling. |
ad-m-ss
commented
Mar 31, 2022
Is there anything what I can do to make that change happen? |
ad-m-ss
commented
Mar 31, 2022
If anyone interested that change can be easily tested eg. via: |
sanguis
commented
Jun 14, 2022
while this is not complete its better then the current fuctionality |
ayk33
commented
Sep 26, 2022
Can we get some traction on this. The previous functionality is much nicer. |
Fez29
commented
Jan 4, 2023
Also waiting on this functionality |
Tlunch
commented
Feb 26, 2024
Would be good to see this functionality |
jannikmi
commented
Aug 23, 2024
I found this functionality in another repository: |
dbowling
commented
Apr 20, 2026
Looks like this also fixes #138 As far as I can see, we're just missing code review. Can any maintainer help? I might suggest that the default be evaluated as it is a change in behavior. Though I personally prefer the default being to auto-fix. |
Restore terraform-fmt behaviour from v0.1.11. Fixes#48.
By default, changes are written back to source files as usual for pre-commit hooks, but can be optionally disabled by providing a
--no-autofixflag to terraform-fmt.