mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Introduce .pre-commit-hooks.yaml as a replacement for hooks.yaml
This commit is contained in:
parent
b90a598fac
commit
b9e5184ebd
32 changed files with 107 additions and 21 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
|
||||
from cached_property import cached_property
|
||||
|
|
@ -8,16 +9,33 @@ import pre_commit.constants as C
|
|||
from pre_commit.clientlib.validate_manifest import load_manifest
|
||||
|
||||
|
||||
logger = logging.getLogger('pre_commit')
|
||||
|
||||
|
||||
class Manifest(object):
|
||||
def __init__(self, repo_path_getter):
|
||||
def __init__(self, repo_path_getter, repo_url):
|
||||
self.repo_path_getter = repo_path_getter
|
||||
self.repo_url = repo_url
|
||||
|
||||
@cached_property
|
||||
def manifest_contents(self):
|
||||
manifest_path = os.path.join(
|
||||
self.repo_path_getter.repo_path, C.MANIFEST_FILE,
|
||||
)
|
||||
return load_manifest(manifest_path)
|
||||
repo_path = self.repo_path_getter.repo_path
|
||||
default_path = os.path.join(repo_path, C.MANIFEST_FILE)
|
||||
legacy_path = os.path.join(repo_path, C.MANIFEST_FILE_LEGACY)
|
||||
if os.path.exists(default_path):
|
||||
return load_manifest(default_path)
|
||||
else:
|
||||
logger.warning(
|
||||
'{} uses legacy {} to provide hooks.\n'
|
||||
'In newer versions, this file is called {}\n'
|
||||
'This will work in this version of pre-commit but will be '
|
||||
'removed at a later time.\n'
|
||||
'If `pre-commit autoupdate` does not silence this warning '
|
||||
'consider making an issue / pull request.'.format(
|
||||
self.repo_url, C.MANIFEST_FILE_LEGACY, C.MANIFEST_FILE,
|
||||
)
|
||||
)
|
||||
return load_manifest(legacy_path)
|
||||
|
||||
@cached_property
|
||||
def hooks(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue