observing/pre-commit

Stash unstaged changed before running tests

Closed this issue · 2 comments

Ref: http://codeinthehole.com/writing/tips-for-using-a-Git-pre-commit-hook/#stash-unstaged-changes-before-running-tests

Helps test only prospective commit.

$ npm test # runs jshint
$ echo "// pass" > pass.js
$ echo "err()" > fail.js
$ git add pass.js
$ npm test # should fail on fail.js
$ git commit -m "should pass"

As the referred article's comments states, there are some serious flaws when it comes to stashing commits. So i'm not fully convinced this is the right way to handle this edgecase?

As a developer, you could just do git stash && git commit when you have unstaged commits that breaks stuff.

Err, didn't see comments w/ Ghostery. Good point!