Skip to content

Commit dbd131f

Browse files
committed
Minor fixups
1 parent 478b0c7 commit dbd131f

4 files changed

Lines changed: 22 additions & 18 deletions

File tree

pre_commit/commands/install_uninstall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def is_previous_pre_commit(filename):
3939

4040
def install(
4141
runner, overwrite=False, hooks=False, hook_type='pre-commit',
42-
skip_on_missing_conf=False
42+
skip_on_missing_conf=False,
4343
):
4444
"""Install the pre-commit hooks."""
4545
hook_path = runner.get_hook_path(hook_type)
@@ -78,7 +78,7 @@ def install(
7878
sys_executable=sys.executable,
7979
hook_type=hook_type,
8080
pre_push=pre_push_contents,
81-
skip_on_missing_conf=skip_on_missing_conf
81+
skip_on_missing_conf=skip_on_missing_conf,
8282
)
8383
pre_commit_file_obj.write(contents)
8484
make_executable(hook_path)

pre_commit/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def main(argv=None):
189189
return install(
190190
runner, overwrite=args.overwrite, hooks=args.install_hooks,
191191
hook_type=args.hook_type,
192-
skip_on_missing_conf=args.allow_missing_config
192+
skip_on_missing_conf=args.allow_missing_config,
193193
)
194194
elif args.command == 'install-hooks':
195195
return install_hooks(runner)

pre_commit/resources/hook-tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ fi
4141
CONF_FILE=$(git rev-parse --show-toplevel)"/.pre-commit-config.yaml"
4242
if [ ! -f $CONF_FILE ]; then
4343
if [ $SKIP_ON_MISSING_CONF = true ] || [ ! -z $PRE_COMMIT_ALLOW_NO_CONFIG ]; then
44-
echo '`.pre-commit-config.yaml` config file not found. Skipping `pre-commit`.'
45-
exit $retv
44+
echo '`.pre-commit-config.yaml` config file not found. Skipping `pre-commit`.'
45+
exit $retv
4646
else
47-
echo 'No .pre-commit-config.yaml file was found\n'\
48-
'- To temporarily silence this, run `PRE_COMMIT_ALLOW_NO_CONFIG=1 git ...`\n'\
49-
'- To permanently silence this, install pre-commit with the `--allow-missing-config` option\n'\
50-
'- To uninstall pre-commit run `pre-commit uninstall`'
47+
echo 'No .pre-commit-config.yaml file was found'
48+
echo '- To temporarily silence this, run `PRE_COMMIT_ALLOW_NO_CONFIG=1 git ...`'
49+
echo '- To permanently silence this, install pre-commit with the `--allow-missing-config` option'
50+
echo '- To uninstall pre-commit run `pre-commit uninstall`'
5151
exit 1
5252
fi
5353
fi

tests/commands/install_uninstall_test.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_install_pre_commit(tempdir_factory):
6666
sys_executable=sys.executable,
6767
hook_type='pre-commit',
6868
pre_push='',
69-
skip_on_missing_conf='false'
69+
skip_on_missing_conf='false',
7070
)
7171
assert pre_commit_contents == expected_contents
7272
assert os.access(runner.pre_commit_path, os.X_OK)
@@ -81,7 +81,7 @@ def test_install_pre_commit(tempdir_factory):
8181
sys_executable=sys.executable,
8282
hook_type='pre-push',
8383
pre_push=pre_push_template_contents,
84-
skip_on_missing_conf='false'
84+
skip_on_missing_conf='false',
8585
)
8686
assert pre_push_contents == expected_contents
8787

@@ -579,8 +579,11 @@ def test_install_allow_mising_config(tempdir_factory):
579579

580580
ret, output = _get_commit_output(tempdir_factory)
581581
assert ret == 0
582-
assert '`.pre-commit-config.yaml` config file not found. '\
583-
'Skipping `pre-commit`.' in output
582+
expected = (
583+
'`.pre-commit-config.yaml` config file not found. '
584+
'Skipping `pre-commit`.'
585+
)
586+
assert expected in output
584587

585588

586589
def test_install_temporarily_allow_mising_config(tempdir_factory):
@@ -591,10 +594,11 @@ def test_install_temporarily_allow_mising_config(tempdir_factory):
591594
remove_config_from_repo(path)
592595
assert install(runner, overwrite=True, skip_on_missing_conf=False) == 0
593596

594-
extra_env = {'PRE_COMMIT_ALLOW_NO_CONFIG': '1'}
595-
env = os.environ.copy()
596-
env.update(extra_env)
597+
env = dict(os.environ, PRE_COMMIT_ALLOW_NO_CONFIG='1')
597598
ret, output = _get_commit_output(tempdir_factory, env=env)
598599
assert ret == 0
599-
assert '`.pre-commit-config.yaml` config file not found. '\
600-
'Skipping `pre-commit`.' in output
600+
expected = (
601+
'`.pre-commit-config.yaml` config file not found. '
602+
'Skipping `pre-commit`.'
603+
)
604+
assert expected in output

0 commit comments

Comments
 (0)