mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 13:00:10 -06:00
Replace string literals with constants
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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',
|
||||
)
|
||||
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user