hookmeup

A Git hook to automate your Pipenv and Django workflow
git clone git://git.danielmoch.com/hookmeup.git
Log | Files | Refs | README | LICENSE

commit 9499724f57a321cea2c0214fd496630224f40b22
parent 18959d4be4dac6912cdf6cba83669413468d737b
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Wed, 29 Aug 2018 07:01:16 -0400

pipenv_changed fix and enhancement

Would fail if Pipfile was excluded from repo, or if there were no
changes. Fix is to avoid assumptions about the length of stdout and
simply check for the existence of 'Pipefile' in the output.

Also enhanced the method to return True if Pipfile.lock changes.

Diffstat:
Mhookmeup/hookmeup.py | 7++++---
Mtests/test_hookmeup.py | 2+-
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hookmeup/hookmeup.py b/hookmeup/hookmeup.py @@ -99,15 +99,16 @@ def pipfile_changed(args): stdout = call_checked_subprocess( ['git', 'diff', - '--name-status', + '--name-only', args['old'], args['new'], '--', - 'Pipfile'], + 'Pipfile', + 'Pipfile.lock'], 'Not in a Git repository' ) - return stdout[0] in ['M', 'A'] + return 'Pipfile' in stdout def post_checkout(args): """Run post-checkout hook""" diff --git a/tests/test_hookmeup.py b/tests/test_hookmeup.py @@ -120,7 +120,7 @@ def test_post_checkout_no_changes(mocker): """Test nominal post_checkout""" mocker.patch( 'subprocess.check_output', - new=mocker.MagicMock(return_value=b'\n') + new=mocker.MagicMock(return_value=b'') ) mocker.patch('hookmeup.hookmeup.adjust_pipenv') hookmeup.hookmeup.post_checkout({