Use set rather than list for commit message related stages, remove

default file open modes, tidy up bash call for failing hook test
This commit is contained in:
Marc Jay 2019-04-21 21:58:01 +01:00
parent 64467f6ab9
commit 82969e4ba3
4 changed files with 5 additions and 5 deletions

View file

@ -190,7 +190,7 @@ def _compute_cols(hooks, verbose):
def _all_filenames(args): def _all_filenames(args):
if args.origin and args.source: if args.origin and args.source:
return git.get_changed_files(args.origin, args.source) return git.get_changed_files(args.origin, args.source)
elif args.hook_stage in ['prepare-commit-msg', 'commit-msg']: elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}:
return (args.commit_msg_filename,) return (args.commit_msg_filename,)
elif args.files: elif args.files:
return args.files return args.files

View file

@ -678,7 +678,7 @@ def test_prepare_commit_msg_integration_passing(
commit_msg_path = os.path.join( commit_msg_path = os.path.join(
prepare_commit_msg_repo, '.git/COMMIT_EDITMSG', prepare_commit_msg_repo, '.git/COMMIT_EDITMSG',
) )
with io.open(commit_msg_path, 'rt') as f: with io.open(commit_msg_path) as f:
assert 'Signed off by: ' in f.read() assert 'Signed off by: ' in f.read()
@ -709,7 +709,7 @@ def test_prepare_commit_msg_legacy(
commit_msg_path = os.path.join( commit_msg_path = os.path.join(
prepare_commit_msg_repo, '.git/COMMIT_EDITMSG', prepare_commit_msg_repo, '.git/COMMIT_EDITMSG',
) )
with io.open(commit_msg_path, 'rt') as f: with io.open(commit_msg_path) as f:
assert 'Signed off by: ' in f.read() assert 'Signed off by: ' in f.read()

View file

@ -615,7 +615,7 @@ def test_prepare_commit_msg_hook(cap_out, store, prepare_commit_msg_repo):
stage=False, stage=False,
) )
with io.open(filename, 'rt') as f: with io.open(filename) as f:
assert 'Signed off by: ' in f.read() assert 'Signed off by: ' in f.read()

View file

@ -171,7 +171,7 @@ def failing_prepare_commit_msg_repo(tempdir_factory):
'hooks': [{ 'hooks': [{
'id': 'add-signoff', 'id': 'add-signoff',
'name': 'Add "Signed off by:"', 'name': 'Add "Signed off by:"',
'entry': '/usr/bin/env bash -c "exit 1"', 'entry': 'bash -c "exit 1"',
'language': 'system', 'language': 'system',
'stages': ['prepare-commit-msg'], 'stages': ['prepare-commit-msg'],
}], }],