Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86d9ca0

Browse files
committed
Remove legacy 'hooks.yaml' file support
1 parent 7aeb4fe commit 86d9ca0

8 files changed

Lines changed: 3 additions & 76 deletions

File tree

hooks.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

pre_commit/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import pkg_resources
44

55
CONFIG_FILE = '.pre-commit-config.yaml'
6-
7-
# In 0.12.0, the default file was changed to be namespaced
86
MANIFEST_FILE = '.pre-commit-hooks.yaml'
9-
MANIFEST_FILE_LEGACY = 'hooks.yaml'
107

118
YAML_DUMP_KWARGS = {
129
'default_flow_style': False,

pre_commit/manifest.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,7 @@ def __init__(self, repo_path, repo_url):
2020

2121
@cached_property
2222
def manifest_contents(self):
23-
default_path = os.path.join(self.repo_path, C.MANIFEST_FILE)
24-
legacy_path = os.path.join(self.repo_path, C.MANIFEST_FILE_LEGACY)
25-
if os.path.exists(legacy_path) and not os.path.exists(default_path):
26-
logger.warning(
27-
'{} uses legacy {} to provide hooks.\n'
28-
'In newer versions, this file is called {}\n'
29-
'This will work in this version of pre-commit but will be '
30-
'removed at a later time.\n'
31-
'If `pre-commit autoupdate` does not silence this warning '
32-
'consider making an issue / pull request.'.format(
33-
self.repo_url, C.MANIFEST_FILE_LEGACY, C.MANIFEST_FILE,
34-
),
35-
)
36-
return load_manifest(legacy_path)
37-
else:
38-
return load_manifest(default_path)
23+
return load_manifest(os.path.join(self.repo_path, C.MANIFEST_FILE))
3924

4025
@cached_property
4126
def hooks(self):

testing/fixtures.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ def config_with_local_hooks():
7979
))
8080

8181

82-
def make_config_from_repo(
83-
repo_path, sha=None, hooks=None, check=True, legacy=False,
84-
):
85-
filename = C.MANIFEST_FILE_LEGACY if legacy else C.MANIFEST_FILE
86-
manifest = load_manifest(os.path.join(repo_path, filename))
82+
def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
83+
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
8784
config = OrderedDict((
8885
('repo', repo_path),
8986
('sha', sha or get_head_sha(repo_path)),

testing/resources/legacy_hooks_yaml_repo/hooks.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/manifest_test.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,6 @@ def test_hooks(manifest):
6060
}
6161

6262

63-
def test_legacy_manifest_warn(store, tempdir_factory, log_warning_mock):
64-
path = make_repo(tempdir_factory, 'legacy_hooks_yaml_repo')
65-
head_sha = get_head_sha(path)
66-
repo_path = store.clone(path, head_sha)
67-
Manifest(repo_path, path).manifest_contents
68-
69-
# Should have printed a warning
70-
assert log_warning_mock.call_args_list[0][0][0] == (
71-
'{} uses legacy hooks.yaml to provide hooks.\n'
72-
'In newer versions, this file is called .pre-commit-hooks.yaml\n'
73-
'This will work in this version of pre-commit but will be removed at '
74-
'a later time.\n'
75-
'If `pre-commit autoupdate` does not silence this warning consider '
76-
'making an issue / pull request.'.format(path)
77-
)
78-
79-
8063
def test_default_python_language_version(store, tempdir_factory):
8164
path = make_repo(tempdir_factory, 'python_hooks_repo')
8265
repo_path = store.clone(path, get_head_sha(path))

tests/meta_test.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/repository_test.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,6 @@ def test_system_hook_with_spaces(tempdir_factory, store):
238238
)
239239

240240

241-
@pytest.mark.integration
242-
def test_repo_with_legacy_hooks_yaml(tempdir_factory, store):
243-
_test_hook_repo(
244-
tempdir_factory, store, 'legacy_hooks_yaml_repo',
245-
'system-hook-with-spaces', ['/dev/null'], b'Hello World\n',
246-
config_kwargs={'legacy': True},
247-
)
248-
249-
250241
@skipif_cant_run_swift
251242
@pytest.mark.integration
252243
def test_swift_hook(tempdir_factory, store):

0 commit comments

Comments
 (0)