Git Some Hooks

Jan 2019 update : There are probably many better ways to do this, I consider this a failed experiment. I plan on repeating this failed experiment at somepoint but using golang instead.

Well, I fell a bit behind on my promise to post at least something weekly.

So here’s a post on git-precommit hooks and how to use them to enforce code quality.

The premise is that enforcing code quality should be automatic.

The git repository at http://github.com/mlctrez/git-hooks should be self explanatory, but here’s a brief rundown from the https://github.com/mlctrez/git-hooks/blob/master/README.md

git-hooks

Git hooks for formatting python, java, and golang files.

Usage

git clone https://github.com/mlctrez/git-hooks

cd git-hooks; python install.py

The installation creates ~/.git_template/hooks/pre-commit and sets the git global init.templatedir to ~/.git_template. New and cloned git repositories will pick up the pre-commit hook.

On a git commit, the precommit.py script executes each hook in the hooks directory. Modify, remove, or add new python scripts in this directory and they will be picked up the next time the pre-commit hook runs.


code

168 Words

2016-07-22 21:12 -0500