Is there a way to run a gruntjs task as precommit hook. For example I want do prevent commits with failing tests or jshint issues. I've also think about to run a code beautifier for every commit.
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
Git hooks are just scripts executed when you do an action like commit. They can contain whatever programming language you'd like.
Example of triggering grunt:
Save this in the file:
.git/hooks/pre-commit
If grunt exits with an error code higher than 0, which it does if any task fail, it will prevent the commit:
Reading material: http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
And the git docs: http://git-scm.com/book/en/Customizing-Git-Git-Hooks
I recently had the same issue and detailed a more comprehensive Grunt solution on http://viget.com/extend/grunt-getting-started-with-git-hooks
I think you should check out grunt-githooks, a nice Grunt plugin that does all the magic for you and lets you easily register Grunt tasks for certain hooks from within your
Gruntfile.js
, such as:(Taken from the docs at https://github.com/wecodemore/grunt-githooks#defining-a-few-hooks)
Find the module on npm here.