From 36cc4d6504e3c630fb336277a1d5c4e98f2fa3ce Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 20 Apr 2012 11:12:56 -0400 Subject: [PATCH] move things around --- README.md | 9 ++++++++- bin/penchant | 6 ++++++ lib/penchant/version.rb | 2 +- script/hooks/commit-msg | 23 +++++++++++++++++++++++ script/hooks/post-commit | 4 ++++ script/hooks/pre-commit | 13 +------------ 6 files changed, 43 insertions(+), 14 deletions(-) create mode 100755 script/hooks/commit-msg create mode 100755 script/hooks/post-commit diff --git a/README.md b/README.md index 999f94f..2878ef3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Installs a bunch of scripts into the `scripts` directory of your project: * `gemfile` which switches between `Gemfile.erb` environments * `install-git-hooks` which will do just what it says -* `hooks/pre-commit`, one of the hooks the prior script installs +* `hooks`, several git hooks that the prior script symlinks into .git/hooks for you * `initialize-environment`, which bootstraps your local environment so you can get up and running ## Gemfile.erb?! @@ -95,6 +95,12 @@ It runs `penchant gemfile remote` then runs `bundle exec rake`. Make sure your d tests and performs any other magic necessary before each commit. Your re-environmented Gemfile and Gemfile.lock will be added to your commit if they've changed. +### Skipping all that Rake falderal? + +Do it Travis CI style: stick `[ci skip]` in your commit message. That's why the meat of hte git hooks resides in +`commit-msg` and not `pre-commit`: you need the commit message before you can determine if the tests should be run +based on the commit message. Weird, I know. + ## How?! * `gem install penchant` @@ -103,5 +109,6 @@ to your commit if they've changed. And then one of the following: * `penchant install` for a new project (`--dir=WHEREVER` will install the scripts to a directory other than `$PWD/scripts`) +* `penchant update` to update the installation (`--dir=WHEVEVER` works here, too) * `penchant convert` for an existing project (`--dir=WHEVEVER` works here, too) diff --git a/bin/penchant b/bin/penchant index 0da8a8a..ca6fffb 100755 --- a/bin/penchant +++ b/bin/penchant @@ -20,6 +20,12 @@ class PenchantCLI < Thor end end + desc "update", "Update the installed scripts" + method_options :dir => 'script' + def update + install + end + desc "convert", "Make an existing project Penchant-isized" method_options :dir => 'script' def convert diff --git a/lib/penchant/version.rb b/lib/penchant/version.rb index 8733841..2b37ff0 100644 --- a/lib/penchant/version.rb +++ b/lib/penchant/version.rb @@ -1,3 +1,3 @@ module Penchant - VERSION = "0.0.5" + VERSION = "0.0.6" end diff --git a/script/hooks/commit-msg b/script/hooks/commit-msg new file mode 100755 index 0000000..439cffd --- /dev/null +++ b/script/hooks/commit-msg @@ -0,0 +1,23 @@ +#!/bin/bash + +msg=$(cat $1) + +OLD_GIT_DIR=$GIT_DIR + +if [[ "${msg}" != *"[ci skip]"* ]]; then + if [ "$(penchant gemfile-env)" != "remote" ]; then + penchant gemfile remote + fi + + bundle exec rake + R=$? + if [ $R -ne 0 ]; then exit $R; fi +fi + +if [ "$(penchant gemfile-env)" != "remote deployment" ]; then + unset GIT_DIR + penchant gemfile remote --deployment + GIT_DIR=$OLD_GIT_DIR + git add Gemfile* +fi + diff --git a/script/hooks/post-commit b/script/hooks/post-commit new file mode 100755 index 0000000..490f85d --- /dev/null +++ b/script/hooks/post-commit @@ -0,0 +1,4 @@ +#!/bin/bash + +penchant gemfile remote --switch-back + diff --git a/script/hooks/pre-commit b/script/hooks/pre-commit index 42c60b3..9ca0347 100755 --- a/script/hooks/pre-commit +++ b/script/hooks/pre-commit @@ -1,15 +1,4 @@ #!/bin/bash -OLD_GIT_DIR=$GIT_DIR - -if [ "$(penchant gemfile-env)" != "remote" ]; then - unset GIT_DIR - penchant gemfile remote --deployment - GIT_DIR=$OLD_GIT_DIR - git add Gemfile* -fi - -bundle exec rake -R=$? -if [ $R -ne 0 ]; then exit $R; fi +# this is now handled in commit-msg, to allow for skipping of test running based on the commit message