Skip to content

Honor excludes; don't run against entire directories (closes #121)#122

Closed
ericfrederich wants to merge 1 commit into
antonbabenko:masterfrom
ericfrederich:fix-excludes
Closed

Honor excludes; don't run against entire directories (closes #121)#122
ericfrederich wants to merge 1 commit into
antonbabenko:masterfrom
ericfrederich:fix-excludes

Conversation

@ericfrederich
Copy link
Copy Markdown

@ericfrederich ericfrederich commented Jun 30, 2020

Closes #121

@bruce-szalwinski
Copy link
Copy Markdown

bruce-szalwinski commented Jul 20, 2020

https://github.com/antonbabenko/pre-commit-terraform/blob/2e40ade8d0bdff4eea5fb64e55d6f40a71768426/CHANGELOG.md#v120---2017-06-08 the exclude option is documented way back in version 1.2.0. Is that no longer working? Was it working previously?

I ran into this while upgrading a module mono repo to 0.12. My client is using the 0.11 version of the module but the 0.12 version of the module comes along for the ride.

When trying to commit my changes on a repo that uses the module, I get:

Error running fmt: In .terraform/modules/26b44daf48f2995f5f7159f55b3e58ba/0.12/datadog.tf: At 5:25: Unknown token: 5:25 IDENT var.monitor_name

I have my pre-commit configured as:

- repo: git://github.com/antonbabenko/pre-commit-terraform
  rev: v1.31.0
  hooks:
    - id: terraform_fmt
      exclude: \.terraform\/.*$

I think it is the same issue that was raised back in #8 from long ago. The hook gets passed the list of files and the dirname is causing issues.

@MaxymVlasov MaxymVlasov added estimate/2h Need 2 hours to be done hook/terraform_fmt Bash hook feature New feature or request labels Sep 9, 2021
@github-actions
Copy link
Copy Markdown

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions Bot added the stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 10, 2021
@MaxymVlasov MaxymVlasov removed the stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 14, 2021
@MaxymVlasov
Copy link
Copy Markdown
Collaborator

Works fine with the latest version

repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
  rev: v1.62.3
  hooks:
  - id: terraform_fmt
    exclude: environment\/.*$

\.terraform\/.*$ excluded globally from Aug 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

estimate/2h Need 2 hours to be done feature New feature or request hook/terraform_fmt Bash hook

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terraform_fmt.sh doesn't respect excludes

3 participants