From d5403f1139d2729a06ed4b6f023e9310b0f2f4b4 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 27 Aug 2012 09:40:41 -0400 Subject: [PATCH] make hooks a little smarter and forgiving --- lib/penchant/version.rb | 2 +- template/script/hooks/commit-msg | 10 +++++++--- template/script/hooks/pre-commit | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/penchant/version.rb b/lib/penchant/version.rb index 8ecc4f5..d36e449 100644 --- a/lib/penchant/version.rb +++ b/lib/penchant/version.rb @@ -1,3 +1,3 @@ module Penchant - VERSION = "0.2.19" + VERSION = "0.2.20" end diff --git a/template/script/hooks/commit-msg b/template/script/hooks/commit-msg index 84d062f..880057a 100755 --- a/template/script/hooks/commit-msg +++ b/template/script/hooks/commit-msg @@ -29,8 +29,12 @@ if [[ "${msg}" != *"[ci skip]"* ]]; then GIT_DIR=$OLD_GIT_DIR fi - bundle exec rake - R=$? - if [ $R -ne 0 ]; then exit $R; fi + if [ $(bundle exec rake -P | grep default | wc -l) -ne 0 ]; then + bundle exec rake + R=$? + if [ $R -ne 0 ]; then exit $R; fi + else + echo "[penchant] No default Rake task found! Add one if you want to run tests before committing." + fi fi diff --git a/template/script/hooks/pre-commit b/template/script/hooks/pre-commit index f402ffb..dfc22bd 100755 --- a/template/script/hooks/pre-commit +++ b/template/script/hooks/pre-commit @@ -1,6 +1,6 @@ #!/bin/bash -if [ $(bundle exec rake -T preflight_check | wc -l) -eq 1 ]; then +if [ $(bundle exec rake -P | grep preflight_check | wc -l) -ne 0 ]; then bundle exec rake preflight_check R=$? if [ $R -ne 0 ]; then exit $R; fi @@ -11,3 +11,4 @@ penchant gemfile remote --deployment GIT_DIR=$OLD_GIT_DIR git add Gemfile* +exit 0