mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add top level minimum_pre_commit_version
This commit is contained in:
parent
264161c182
commit
c78b6967cd
2 changed files with 37 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ from identify.identify import ALL_TAGS
|
|||
import pre_commit.constants as C
|
||||
from pre_commit.error_handler import FatalError
|
||||
from pre_commit.languages.all import all_languages
|
||||
from pre_commit.util import parse_version
|
||||
|
||||
|
||||
def check_type_tag(tag):
|
||||
|
|
@ -23,6 +24,16 @@ def check_type_tag(tag):
|
|||
)
|
||||
|
||||
|
||||
def check_min_version(version):
|
||||
if parse_version(version) > parse_version(C.VERSION):
|
||||
raise cfgv.ValidationError(
|
||||
'pre-commit version {} is required but version {} is installed. '
|
||||
'Perhaps run `pip install --upgrade pre-commit`.'.format(
|
||||
version, C.VERSION,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _make_argparser(filenames_help):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*', help=filenames_help)
|
||||
|
|
@ -231,6 +242,11 @@ CONFIG_SCHEMA = cfgv.Map(
|
|||
),
|
||||
cfgv.Optional('exclude', cfgv.check_regex, '^$'),
|
||||
cfgv.Optional('fail_fast', cfgv.check_bool, False),
|
||||
cfgv.Optional(
|
||||
'minimum_pre_commit_version',
|
||||
cfgv.check_and(cfgv.check_string, check_min_version),
|
||||
'0',
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue