From 1ee485dee30bbf96fbfbeda0f20f976ff616d226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Guimar=C3=A3es?= Date: Sun, 1 May 2016 09:27:12 -0300 Subject: [PATCH] adds pre-commit hook --- pre-commit.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 pre-commit.sh diff --git a/pre-commit.sh b/pre-commit.sh new file mode 100755 index 0000000..94a0d26 --- /dev/null +++ b/pre-commit.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# +# Our "pre-commit" hook. + +# stash modified files not part of this commit, don't test them +echo "\n\nStashing any modified files not part of commit\n\n" +git stash -q --keep-index + +# do the commit tests +echo "\n\nRunning commit tests...\n\n" +tox +RESULT=$? + +# restore modified files not part of this commit +echo "\n\nPopping any stashed modified files not part of commit\n" +git stash pop -q + +[ $RESULT -ne 0 ] && echo "\nOops, your commit failed\n" && exit 1 + +echo "\nCommit tests passed!\n" +exit 0