Skip to content

Conversation

rwbot
Copy link

@rwbot rwbot commented Aug 29, 2025

This pull request introduces a new pre-commit hook to prevent accidental commits of .env files containing sensitive information, along with supporting documentation, configuration, and testing resources. The main addition is the catch-dotenv hook, which blocks .env files from being committed, optionally generates a sanitized .env.example, and ensures .env is listed in .gitignore.

New pre-commit hook for dotenv protection:

  • Added the catch-dotenv hook implementation in pre_commit_hooks/catch_dotenv.py, which blocks commits of .env files, can generate a .env.example with only variable names, and ensures .env is present in .gitignore.
  • Registered the new hook in .pre-commit-hooks.yaml with a description and configuration options.
  • Documented usage, options, and benefits of catch-dotenv in README.md.

Integration and testing resources:

  • Added catch-dotenv to the setup.cfg entry points to enable command-line usage and integration with pre-commit.
  • Included a sample .env file with dummy secrets in testing/resources/test.env for testing.

@asottile
Copy link
Member

hi in the future please discuss features before spending time on them

you don't really need any code for this. this can be done trivially with a language: fail hook

@asottile asottile closed this Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants