Skip to content

Conversation

@manics
Copy link

@manics manics commented Oct 21, 2022

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.

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.
name: Git Secrets
description: git-secrets scans commits, commit messages, and --no-ff merges to prevent adding secrets into your git repositories.
entry: 'git-secrets --pre_commit_hook'
entry: pre-commit-hook-exec.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead just do entry: './git-secrets --pre-commit-hook' (possibly even minus the quotes)?

I am not too familiar with pre-commit so I understand I might be missing some context here.

That said, your solution may also be preferable if your use of git secrets causes existing git configuration to be honored in a way that directly calling the git-secrets script does not.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants