mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
Merge pull request #687 from pre-commit/deprecate_pcre
Deprecate the pcre language
This commit is contained in:
commit
c8fd92e368
2 changed files with 40 additions and 2 deletions
|
|
@ -67,6 +67,15 @@ def _run_single_hook(filenames, hook, repo, args, skips, cols):
|
||||||
filenames = _filter_by_include_exclude(filenames, include, exclude)
|
filenames = _filter_by_include_exclude(filenames, include, exclude)
|
||||||
types, exclude_types = hook['types'], hook['exclude_types']
|
types, exclude_types = hook['types'], hook['exclude_types']
|
||||||
filenames = _filter_by_types(filenames, types, exclude_types)
|
filenames = _filter_by_types(filenames, types, exclude_types)
|
||||||
|
|
||||||
|
if hook['language'] == 'pcre':
|
||||||
|
logger.warning(
|
||||||
|
'`{}` (from {}) uses the deprecated pcre language.\n'
|
||||||
|
'The pcre language is scheduled for removal in pre-commit 2.x.\n'
|
||||||
|
'The pygrep language is a more portable (and usually drop-in) '
|
||||||
|
'replacement.'.format(hook['id'], repo.repo_config['repo']),
|
||||||
|
)
|
||||||
|
|
||||||
if hook['id'] in skips:
|
if hook['id'] in skips:
|
||||||
output.write(get_hook_message(
|
output.write(get_hook_message(
|
||||||
_hook_msg_start(hook, args.verbose),
|
_hook_msg_start(hook, args.verbose),
|
||||||
|
|
|
||||||
|
|
@ -529,7 +529,7 @@ def test_push_hook(cap_out, repo_with_passing_hook, mock_out_store_directory):
|
||||||
('id', 'do_not_commit'),
|
('id', 'do_not_commit'),
|
||||||
('name', 'hook 2'),
|
('name', 'hook 2'),
|
||||||
('entry', 'DO NOT COMMIT'),
|
('entry', 'DO NOT COMMIT'),
|
||||||
('language', 'pcre'),
|
('language', 'pygrep'),
|
||||||
('types', ['text']),
|
('types', ['text']),
|
||||||
('stages', ['push']),
|
('stages', ['push']),
|
||||||
)),
|
)),
|
||||||
|
|
@ -592,7 +592,7 @@ def test_local_hook_passes(
|
||||||
('id', 'do_not_commit'),
|
('id', 'do_not_commit'),
|
||||||
('name', 'Block if "DO NOT COMMIT" is found'),
|
('name', 'Block if "DO NOT COMMIT" is found'),
|
||||||
('entry', 'DO NOT COMMIT'),
|
('entry', 'DO NOT COMMIT'),
|
||||||
('language', 'pcre'),
|
('language', 'pygrep'),
|
||||||
('files', '^(.*)$'),
|
('files', '^(.*)$'),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
|
@ -645,6 +645,35 @@ def test_local_hook_fails(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_pcre_deprecation_warning(
|
||||||
|
cap_out, repo_with_passing_hook, mock_out_store_directory,
|
||||||
|
):
|
||||||
|
config = OrderedDict((
|
||||||
|
('repo', 'local'),
|
||||||
|
(
|
||||||
|
'hooks', [OrderedDict((
|
||||||
|
('id', 'pcre-hook'),
|
||||||
|
('name', 'pcre-hook'),
|
||||||
|
('language', 'pcre'),
|
||||||
|
('entry', '.'),
|
||||||
|
))],
|
||||||
|
),
|
||||||
|
))
|
||||||
|
add_config_to_repo(repo_with_passing_hook, config)
|
||||||
|
|
||||||
|
_test_run(
|
||||||
|
cap_out,
|
||||||
|
repo_with_passing_hook,
|
||||||
|
opts={},
|
||||||
|
expected_outputs=[
|
||||||
|
b'[WARNING] `pcre-hook` (from local) uses the deprecated '
|
||||||
|
b'pcre language.',
|
||||||
|
],
|
||||||
|
expected_ret=0,
|
||||||
|
stage=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_meta_hook_passes(
|
def test_meta_hook_passes(
|
||||||
cap_out, repo_with_passing_hook, mock_out_store_directory,
|
cap_out, repo_with_passing_hook, mock_out_store_directory,
|
||||||
):
|
):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue