mirror of
https://github.com/saymrwulf/zipline.git
synced 2026-05-16 21:10:11 +00:00
So that the code that is linted/tested is only the staged commits. Useful when editing by only staging parts of files via git.
29 lines
791 B
Bash
Executable file
29 lines
791 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# An hook script to verify linting and passing unit tests.
|
|
#
|
|
# Called by "git commit" with no arguments. The hook should
|
|
# exit with non-zero status after issuing an appropriate message if
|
|
# it wants to stop the commit.
|
|
#
|
|
# To enable this hook, copy or symlink to your repo's
|
|
# ".git/hooks/pre-commit".
|
|
#
|
|
# Please read the following as it will execute on your machine on each commit.
|
|
|
|
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
|