gruntwork-io / pre-commit

A collection of pre-commit hooks used by Gruntwork tools
https://gruntwork.io/
Apache License 2.0
494 stars 157 forks source link

terraform-fmt updates files, optionally skipped via flags #53

Open tyron opened 3 years ago

tyron commented 3 years ago

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.

tyron commented 3 years ago

@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.

joshmyers commented 2 years ago

Any movement on this? Seems a few folks would like old behavior

mleuthold commented 2 years ago

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 2 years ago

+1 on this change. Printing the diff is not as useful as auto-correcting the styling.

ad-m-ss commented 2 years ago

Is there anything what I can do to make that change happen?

ad-m-ss commented 2 years ago

If anyone interested that change can be easily tested eg. via:

- repo: https://github.com/gruntwork-io/pre-commit
  rev: 837cfa83f27ec2dd4a4c6860b2a6ca9392642fe0
  hooks:
    - id: terraform-fmt
    - id: terraform-validate
      exclude: terragrunt/modules
sanguis commented 2 years ago

while this is not complete its better then the current fuctionality

ayk33 commented 2 years ago

Can we get some traction on this. The previous functionality is much nicer.

Fez29 commented 1 year ago

Also waiting on this functionality

Tlunch commented 8 months ago

Would be good to see this functionality

jannikmi commented 2 months ago

I found this functionality in another repository: https://github.com/antonbabenko/pre-commit-terraform?tab=readme-ov-file#terraform_fmt

    - repo: https://github.com/antonbabenko/pre-commit-terraform
      rev: v1.92.2
      hooks:
          - id: terraform_fmt