-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform-fmt updates files, optionally skipped via flags #53
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inspired on shellcheck.sh
's version:
pre-commit/hooks/shellcheck.sh
Line 13 in e9250bd
parse_arguments() { |
Any movement on this? Seems a few folks would like old behavior |
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. |
+1 on this change. Printing the diff is not as useful as auto-correcting the styling. |
Is there anything what I can do to make that change happen? |
If anyone interested that change can be easily tested eg. via:
|
while this is not complete its better then the current fuctionality |
Can we get some traction on this. The previous functionality is much nicer. |
Also waiting on this functionality |
Would be good to see this functionality |
I found this functionality in another repository:
|
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-autofix
flag to terraform-fmt.