Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82969e4

Browse files
committed
Use set rather than list for commit message related stages, remove
default file open modes, tidy up bash call for failing hook test
1 parent 64467f6 commit 82969e4

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

pre_commit/commands/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _compute_cols(hooks, verbose):
190190
def _all_filenames(args):
191191
if args.origin and args.source:
192192
return git.get_changed_files(args.origin, args.source)
193-
elif args.hook_stage in ['prepare-commit-msg', 'commit-msg']:
193+
elif args.hook_stage in {'prepare-commit-msg', 'commit-msg'}:
194194
return (args.commit_msg_filename,)
195195
elif args.files:
196196
return args.files

tests/commands/install_uninstall_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def test_prepare_commit_msg_integration_passing(
678678
commit_msg_path = os.path.join(
679679
prepare_commit_msg_repo, '.git/COMMIT_EDITMSG',
680680
)
681-
with io.open(commit_msg_path, 'rt') as f:
681+
with io.open(commit_msg_path) as f:
682682
assert 'Signed off by: ' in f.read()
683683

684684

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

715715

tests/commands/run_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def test_prepare_commit_msg_hook(cap_out, store, prepare_commit_msg_repo):
615615
stage=False,
616616
)
617617

618-
with io.open(filename, 'rt') as f:
618+
with io.open(filename) as f:
619619
assert 'Signed off by: ' in f.read()
620620

621621

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def failing_prepare_commit_msg_repo(tempdir_factory):
171171
'hooks': [{
172172
'id': 'add-signoff',
173173
'name': 'Add "Signed off by:"',
174-
'entry': '/usr/bin/env bash -c "exit 1"',
174+
'entry': 'bash -c "exit 1"',
175175
'language': 'system',
176176
'stages': ['prepare-commit-msg'],
177177
}],

0 commit comments

Comments
 (0)