From 060b565cdcf67ff40fd6437b78cc9db8b96400e8 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 20 Mar 2013 11:00:38 -0400 Subject: [PATCH] DEV: Adds stashing to pre-commit hook. So that the code that is linted/tested is only the staged commits. Useful when editing by only staging parts of files via git. --- etc/git-hooks/pre-commit | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/etc/git-hooks/pre-commit b/etc/git-hooks/pre-commit index 83352197..c1d771cb 100755 --- a/etc/git-hooks/pre-commit +++ b/etc/git-hooks/pre-commit @@ -13,7 +13,17 @@ set -e +# stash everything that wasn't just staged +# so that we are only testing the staged code +git stash -q --keep-index + # Run flake8 linting flake8 zipline tests # Run unit tests nosetests -x + +# restore unstaged code +# N.B. this won't run if linting or unit tests fail +# But if either fail, it's probably best to have only the offending +# staged commits 'active', anyway. +git stash pop -q