git - Create pre-push hook to lint/test -
i wondering best way create pre-push hook (in git repo) following:
- run jshint / jslint
- run unit , functional tests
- if ok accept update
- otherwise refuse update
you use git pre commit hook this. i've set pre commit hooks check debug statements, etc.
client side hooks belong in .git/hooks folder. since can't commit in .git repo version control you're kind of stuck.
what need keep shell command checks correctness in folder in git repo, top level tools directory.
then "just" tell people install via:
chmod u+x tools/precommit-checks.sh ln -s $pwd/tools/precommit-checks.sh .git/hooks/pre-commit and, assuming installs it, can have checking ask.
probably better way catch server side: have kind of continuous integration server pulling latest commits github repo , checking codebase.
no, won't give "deny push" capabilities you'd like.
assuming host git repo yourself, there's wrinkle: thought pre-receive hooks on server hang clients long hook takes. (this is documented true post-recieve hooks, i'm guessing it's true here too). if ci tests take 2 minutes developer typing git push , waiting 2 minutes console again.
so better post push analysis using ci server or other quality tests.
Comments
Post a Comment