From 8407b92b18f92b7c012d913e4de760d41efe2c31 Mon Sep 17 00:00:00 2001 From: Iulian Onofrei Date: Tue, 9 Jan 2018 17:51:41 +0200 Subject: [PATCH] Replace string literals with constants --- pre_commit/commands/run.py | 9 +++++---- pre_commit/main.py | 2 +- pre_commit/repository.py | 4 ++-- testing/fixtures.py | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index 3a08c8d8..71fb43e7 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -9,6 +9,7 @@ import sys from identify.identify import tags_from_path +import pre_commit.constants as C from pre_commit import color from pre_commit import git from pre_commit import output @@ -222,10 +223,10 @@ def run(runner, args, environ=os.environ): logger.error('Specify both --origin and --source.') return 1 if _has_unstaged_config(runner) and not no_stash: - logger.error( - 'Your .pre-commit-config.yaml is unstaged.\n' - '`git add .pre-commit-config.yaml` to fix this.', - ) + logger.error(( + 'Your {0} is unstaged.\n' + '`git add {0}` to fix this.' + ).format(C.CONFIG_FILE),) return 1 # Expose origin / source as environment variables for hooks to consume diff --git a/pre_commit/main.py b/pre_commit/main.py index 4c9202ad..865571a5 100644 --- a/pre_commit/main.py +++ b/pre_commit/main.py @@ -42,7 +42,7 @@ def _add_color_option(parser): def _add_config_option(parser): parser.add_argument( - '-c', '--config', default='.pre-commit-config.yaml', + '-c', '--config', default=C.CONFIG_FILE, help='Path to alternate config file', ) diff --git a/pre_commit/repository.py b/pre_commit/repository.py index bc0ecad3..5c11921c 100644 --- a/pre_commit/repository.py +++ b/pre_commit/repository.py @@ -269,14 +269,14 @@ class MetaRepository(LocalRepository): { 'id': 'check-hooks-apply', 'name': 'Check hooks apply to the repository', - 'files': '.pre-commit-config.yaml', + 'files': C.CONFIG_FILE, 'language': 'system', 'entry': _make_entry(check_hooks_apply), }, { 'id': 'check-useless-excludes', 'name': 'Check for useless excludes', - 'files': '.pre-commit-config.yaml', + 'files': C.CONFIG_FILE, 'language': 'system', 'entry': _make_entry(check_useless_excludes), }, diff --git a/testing/fixtures.py b/testing/fixtures.py index b1c7a89f..edb1bcdf 100644 --- a/testing/fixtures.py +++ b/testing/fixtures.py @@ -47,7 +47,7 @@ def modify_manifest(path): with io.open(manifest_path, 'w') as manifest_file: manifest_file.write(ordered_dump(manifest, **C.YAML_DUMP_KWARGS)) cmd_output( - 'git', 'commit', '-am', 'update .pre-commit-hooks.yaml', cwd=path, + 'git', 'commit', '-am', 'update {}'.format(C.MANIFEST_FILE), cwd=path, )