Don't require overwrite of existing pre-commit hooks
acaloiaro opened this issue · 3 comments
When running env-sample-sync install
, if a git pre-commit hook is already installed, env-sample-sync
gives the user the option (yes/no) to overwrite the existing one. This is not ideal because the user should have the option to retain any existing pre-commit hooks. This should be relatively easy to fix.
The way env-sample-sync install
works is by installing the hook to .git/hooks/pre-commit
.
- Checks whether a hook is already installed and provides an option to overwrite the existing one
- Creates a directory named
pre-commit-hooks.d
- Makes a copy of itself (the binary) and places it in
pre-commit-hooks.d
- Writes its own
pre-commit
bash script to.git/hooks/pre-commit
4.1 This script executes all executables inpre-commit-hooks.d
.
To make the changes for this issue, between (2.) and (3.), add a step to copy any existing pre-commit
script into pre-commit-hooks.d
before writing env-sample-sync
's pre-commit
script.
Hi @acaloiaro will love to work on this
Cool! Let me know if there's anything I can make more clear, and if you want to chat in real time, there's a Gitter channel here: https://app.gitter.im/#/room/#env-sample-sync-dev:gitter.im