Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Be able to run pre-commit check on file removal (for languages which not file-limited, but dir-limited) #3048

Copy link
Copy link
Closed
@MaxymVlasov

Description

@MaxymVlasov
Issue body actions

search you tried in the issue tracker

file removal

describe your actual problem

I'm maintainer of Terraform pre-commit hooks, and Terraform during checks and execution, merges all *.tf, *.tfvars, and few other file extensions in one folder in one big configuration and checks that across all these files everything is OK.

For example, we have 2 files in one directory:

vars.tf

variable "kms_enabled" {
  description = "Enable creation of app-specific KMS key. Required if S3 or RDS is enabled."
  type        = bool
  default     = false
}

outputs.tf

output "kms_enabled" {
  description = "Is KMS used"
  value       = var.kms_enabled
}

If everything that I do in the folder - removes vars.tf - pre-commit will skip any checks which means that we commit invalid code.

In terraform hooks, we get all the changed file paths, extract dir paths and execute hooks on dirs.
https://github.com/antonbabenko/pre-commit-terraform/blob/7122298824a9530e8f9c48e5de4281cca6301d67/hooks/_common.sh#L245C27-L253

Is there any possibility of forcing pre-commit to not skip deleted file paths from the list of files that need to be checked?

pre-commit --version

pre-commit 3.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.