Replace string literals with constants

This commit is contained in:
Iulian Onofrei 2018-01-09 17:51:41 +02:00
parent a5f3cefb64
commit 8407b92b18
4 changed files with 9 additions and 8 deletions

View file

@ -9,6 +9,7 @@ import sys
from identify.identify import tags_from_path from identify.identify import tags_from_path
import pre_commit.constants as C
from pre_commit import color from pre_commit import color
from pre_commit import git from pre_commit import git
from pre_commit import output from pre_commit import output
@ -222,10 +223,10 @@ def run(runner, args, environ=os.environ):
logger.error('Specify both --origin and --source.') logger.error('Specify both --origin and --source.')
return 1 return 1
if _has_unstaged_config(runner) and not no_stash: if _has_unstaged_config(runner) and not no_stash:
logger.error( logger.error((
'Your .pre-commit-config.yaml is unstaged.\n' 'Your {0} is unstaged.\n'
'`git add .pre-commit-config.yaml` to fix this.', '`git add {0}` to fix this.'
) ).format(C.CONFIG_FILE),)
return 1 return 1
# Expose origin / source as environment variables for hooks to consume # Expose origin / source as environment variables for hooks to consume

View file

@ -42,7 +42,7 @@ def _add_color_option(parser):
def _add_config_option(parser): def _add_config_option(parser):
parser.add_argument( parser.add_argument(
'-c', '--config', default='.pre-commit-config.yaml', '-c', '--config', default=C.CONFIG_FILE,
help='Path to alternate config file', help='Path to alternate config file',
) )

View file

@ -269,14 +269,14 @@ class MetaRepository(LocalRepository):
{ {
'id': 'check-hooks-apply', 'id': 'check-hooks-apply',
'name': 'Check hooks apply to the repository', 'name': 'Check hooks apply to the repository',
'files': '.pre-commit-config.yaml', 'files': C.CONFIG_FILE,
'language': 'system', 'language': 'system',
'entry': _make_entry(check_hooks_apply), 'entry': _make_entry(check_hooks_apply),
}, },
{ {
'id': 'check-useless-excludes', 'id': 'check-useless-excludes',
'name': 'Check for useless excludes', 'name': 'Check for useless excludes',
'files': '.pre-commit-config.yaml', 'files': C.CONFIG_FILE,
'language': 'system', 'language': 'system',
'entry': _make_entry(check_useless_excludes), 'entry': _make_entry(check_useless_excludes),
}, },

View file

@ -47,7 +47,7 @@ def modify_manifest(path):
with io.open(manifest_path, 'w') as manifest_file: with io.open(manifest_path, 'w') as manifest_file:
manifest_file.write(ordered_dump(manifest, **C.YAML_DUMP_KWARGS)) manifest_file.write(ordered_dump(manifest, **C.YAML_DUMP_KWARGS))
cmd_output( cmd_output(
'git', 'commit', '-am', 'update .pre-commit-hooks.yaml', cwd=path, 'git', 'commit', '-am', 'update {}'.format(C.MANIFEST_FILE), cwd=path,
) )