diff --git a/pre_commit/resources/pre-commit-hook b/pre_commit/resources/pre-commit-hook index 3ddf8943..bdb1431d 100755 --- a/pre_commit/resources/pre-commit-hook +++ b/pre_commit/resources/pre-commit-hook @@ -2,7 +2,9 @@ # This is a randomish md5 to identify this script # 4d9958c90bc262f47553e2c073f14cfe -HERE=$(dirname $(readlink -f "$0")) +pushd `dirname $0` > /dev/null +HERE=`pwd` +popd > /dev/null retv=0 diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py index 14fafa1a..bb511384 100644 --- a/tests/commands/install_uninstall_test.py +++ b/tests/commands/install_uninstall_test.py @@ -100,13 +100,23 @@ def _get_commit_output(tmpdir_factory, touch_file='foo'): )[:2] +# osx does this different :( +FILES_CHANGED = ( + r'(' + r' 1 file changed, 0 insertions\(\+\), 0 deletions\(-\)\n' + r'|' + r' 0 files changed\n' + r')' +) + + NORMAL_PRE_COMMIT_RUN = re.compile( r'^\[INFO\] Installing environment for .+\.\n' r'\[INFO\] Once installed this environment will be reused\.\n' r'\[INFO\] This may take a few minutes\.\.\.\n' r'Bash hook\.+Passed\n' - r'\[master [a-f0-9]{7}\] Commit!\n' - r' 0 files changed\n' + r'\[master [a-f0-9]{7}\] Commit!\n' + + FILES_CHANGED + r' create mode 100644 foo\n$' ) @@ -174,8 +184,8 @@ def test_failing_hooks_returns_nonzero(tmpdir_factory): EXISTING_COMMIT_RUN = re.compile( r'^legacy hook\n' - r'\[master [a-f0-9]{7}\] Commit!\n' - r' 0 files changed\n' + r'\[master [a-f0-9]{7}\] Commit!\n' + + FILES_CHANGED + r' create mode 100644 baz\n$' )