mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-14 17:41:45 +04:00
Replace string literals with constants
This commit is contained in:
parent
a5f3cefb64
commit
8407b92b18
4 changed files with 9 additions and 8 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue