Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Template Config for git

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


How to install

  1. Clone this repostory
  2. Run ./install.sh (this creates a few symlinks)
  3. Tell git where to look for git hooks: git config --global core.hooksPath /path/to/this/repo/scripts
  4. Git will now automatically run this hook and then look for .git-pre-commit files in a project for project specific hooks.

What the pre-commit hook checks

  1. .gitignore exists.
  2. No blacklisted string is in the staged content.
  3. The checks configured outside this repo, if any.
  4. The project's own .git-pre-commit, if it has one.

Blacklist

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/blacklist for every repo on this machine
  • <repo>/.git/blacklist.local for 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.

External checks

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.

About

Git utilities (hooks etc)

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages