awslabs / git-secrets

Prevents you from committing secrets and credentials into git repositories
Apache License 2.0
12.36k stars 1.17k forks source link

pre-commit hook can be run without installing git-secrets #225

Open manics opened 1 year ago

manics commented 1 year ago

Issue #, if available: -

Description of changes: At present if you want to use the git-secrets pre-commit hook you must first follow the git-secrets installation instructions. In contrast many other pre-commit hooks are designed to be self-contained, they automatically install themselves to a directory controlled by pre-commit when pre-commit run is called. This improves the developer experience of projects using this hook, since new developers can just run pre-commit ... without any pre-requisite setup.

This PR changes the pre-commit hook entry to a wrapper script that detects the location of the cloned git-secrets directory, and adds it to PATH so git secrets can be run without any manual setup.

A further benefit is that the version of git-secrets used will match the git revision specified in the .pre-commit-config.yaml instead of whatever version the user has installed.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.