The data in 'template' will be placed inside '.git' when running git init.
NOTE: the actual hook scripts are in the folder 'scripts', while the template directory only contains symlinks.
This is done so that repositories always use the latest version of the scripts.
Note: templates work because ~/.gitconfig has the following:
[init]
templateDir = ~/git/template
- Clone this repostory
- Run
./install.sh(this creates a few symlinks) - Tell git where to look for git hooks:
git config --global core.hooksPath /path/to/this/repo/scripts - Git will now automatically run this hook and then look for
.git-pre-commitfiles in a project for project specific hooks.
.gitignoreexists.- No blacklisted string is in the staged content.
- The checks configured outside this repo, if any.
- The project's own
.git-pre-commit, if it has one.
str_blacklist in scripts/pre-commit is committed and should stay generic. Machine paths,
customer names and anything else specific to you go in a file that is not committed, one string
per line, # for a comment:
~/.config/jitter-git/blacklistfor every repo on this machine<repo>/.git/blacklist.localfor one repo
The check reads the staged content, so removing the string from the working copy after staging it does not get it past the hook.
Point the hook at scripts that live outside this repo, and it runs each with --staged. A
non-zero exit fails the commit.
~/.config/jitter-git/checks-path, one path per line, a file or a directory of*.py$JITTER_PRECOMMIT_CHECKS, the same syntax, with:between paths
The config file is the better default. An environment variable has to come from a shell profile, and an IDE or a GUI git client often does not load one.