pimterry / git-confirm
- пятница, 5 августа 2016 г. в 03:14:34
Shell
❓ Git hook to catch placeholders and temporary changes (TODO / @ignore ) before you commit them.
Git hook to catch placeholders and temporary changes (TODO / @ignore) before you commit them.
Git Confirm:
add
ed and about to be committed, so no false positives.In the root of your Git repository, run:
curl https://cdn.rawgit.com/pimterry/git-confirm/v0.2.1/hook.sh > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
(Note the version number)
All done. If you want to check it's installed correctly you can run:
echo "TODO" > ./test-git-confirm
git add ./test-git-confirm
# Should prompt you to confirm added 'TODO'. Press 'n' to cancel commit.
git commit -m "Testing git confirm"
If you're security conscious, you may be reasonably suspicious of curling executable files. Here you're on HTTPS throughout though, and you're not piping directly to execution so you can check contents and the hash (against MD5 04baf1f87974681a92ee7fe8c0aa3aaa for v0.2.1) before using this, if you like.
By default, git-confirm will catch and warn about lines including 'TODO' only.
If you want to match a different pattern, you can override this default and set your own patterns:
git config --add hooks.confirm.match "TODO"
Matches are passed verbatim to your local grep
, and are treated as regular expressions. Note that all matches are case-sensitive.
You can repeatedly add patterns, and each of them will be matched in turn. To get, remove or totally clear your config, use the standard Git Config commands:
git config --get-all hooks.confirm.match
git config --unset hooks.confirm.match 'TODO'
git config --unset-all hooks.confirm.match
Want to file a bug? That's great! Please search issues first though to check it hasn't already been filed, and provide as much information as you can (your OS, terminal and Git-Confirm version as a minimum).
Want to help improve Git-Confirm?
Check out the project:
git clone --recursive https://github.com/pimterry/git-confirm.git
(Note 'recursive' - this ensures submodules are included)
./test.sh
Add tests for your change in test/test-hook.bats
Check out the BATS documentation if you're not familiar with it, or just crib from the existing tests.
Need any ideas? Take a look at the Git Confirm Huboard to quickly see the next features to look at.
md5 ./hook.sh
) in README.git tag vX.Y.Z
)git push origin --tags
)