Skip to content

BUG: pre-commit script to find .env has bad regex #772

@tomwillis608

Description

@tomwillis608

In the script to prevent the submission of .env files, there is a regex bug, per ChatGPT

Actual:
the script

#!/bin/sh
if git diff --cached --name-only | grep -q "^.env$"; then
    echo "Error: Attempt to commit forbidden file '.env'"
    exit 1
fi

Fix:

We escape each literal dot with \. so \.env only matches files that start with a dot.

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