Closed jamiekt closed 1 year ago
pre-commit is verifying/updating all files matching, not just files you've modified.
To avoid confusion in the future, ask your teammates to install pre-commit
and use it every time. It will not change all the files unless there are changes in them.
Appreciate the quick response @antonbabenko. I'm afraid I don't understand this though:
pre-commit is verifying/updating all files matching, not just files you've modified.
What do you mean by "all files matching"? Only one file has been changed, so what are these files "matching"?
I mean that terraform_fmt
hook scans files defined here - all .tf files.
I mean that
terraform_fmt
hook scans files defined here - all .tf files.
got it, thank you. And donation incoming, hugely appreciate what you do here.
By the way, @jamiekt feel free to add pre-commit to your CI, then you will force everyone to use pre-commit at least on PR creation stage.
IE: https://github.com/antonbabenko/pre-commit-terraform/blob/master/.github/workflows/pre-commit.yaml
Ooo interesting. Thx Maxym
Describe the bug
I have changed 1 file in my terraform configuration.
diff is showing one change:
However I then commit my small change and pre-commit formats all the files in the directory:
Ostensibly its not a big problem but there are folks on my team that are uncomfortable making so many changes in a single commit when all they really want to do is make a minor change to one file/
How can we reproduce it?
Not sure that you can. I've used this pre-commit hook many times in the past and never experienced this before. I have attempted to reproduce it by running
terraform fmt
manually but I didn't get the same behaviour.Environment information
OS:
OS: MacOS
uname -a
and/orsysteminfo | Select-String "^OS"
output:.pre-commit-config.yaml
:file content
```bash --- repos: - repo: https://github.com/antonbabenko/pre-commit-terraform rev: v1.77.1 hooks: - id: terraform_fmt - id: terraform_validate - id: terraform_tflint - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - id: check-added-large-files - id: forbid-new-submodules - id: pretty-format-json args: - --no-sort-keys - --autofix # pretty-format-yaml from # https://github.com/macisamuele/language-formatters-pre-commit-hooks # doesn't jive well with yamllint which is used in super-linter, so # following the advice at # https://github.com/jumanjihouse/pre-commit-hook-yamlfmt#combine-with-yamllint # to use the following instead - repo: https://github.com/adrienverge/yamllint.git rev: v1.29.0 hooks: - id: yamllint args: [--format, parsable, --strict] - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt rev: 0.2.2 hooks: - id: yamlfmt - repo: https://github.com/psf/black rev: 23.1.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 rev: 6.0.0 hooks: - id: flake8 args: - --max-line-length=110 - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.0.1 hooks: - id: mypy name: mypy src files: src ```