mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
Allow to simply run a script once - no matter what the changes are
This commit is contained in:
parent
577d8a1dfa
commit
5a08204b8d
3 changed files with 12 additions and 4 deletions
|
|
@ -32,6 +32,7 @@ CONFIG_JSON_SCHEMA = {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
'id': {'type': 'string'},
|
'id': {'type': 'string'},
|
||||||
|
'always_run': {'type': 'boolean'},
|
||||||
'files': {'type': 'string'},
|
'files': {'type': 'string'},
|
||||||
'exclude': {'type': 'string'},
|
'exclude': {'type': 'string'},
|
||||||
'language_version': {'type': 'string'},
|
'language_version': {'type': 'string'},
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ MANIFEST_JSON_SCHEMA = {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
'id': {'type': 'string'},
|
'id': {'type': 'string'},
|
||||||
|
'always_run': {'type': 'boolean'},
|
||||||
'name': {'type': 'string'},
|
'name': {'type': 'string'},
|
||||||
'description': {'type': 'string', 'default': ''},
|
'description': {'type': 'string', 'default': ''},
|
||||||
'entry': {'type': 'string'},
|
'entry': {'type': 'string'},
|
||||||
|
|
|
||||||
|
|
@ -72,13 +72,19 @@ def get_filenames(args, include_expr, exclude_expr):
|
||||||
|
|
||||||
|
|
||||||
def _run_single_hook(hook, repo, args, write, skips=frozenset()):
|
def _run_single_hook(hook, repo, args, write, skips=frozenset()):
|
||||||
filenames = get_filenames(args, hook['files'], hook['exclude'])
|
filenames = []
|
||||||
|
# if the hook is marked as always_run, do not compute the files to run
|
||||||
|
# in that case, simply run the script once not matter the changes
|
||||||
|
compute_file_names = 'always_run' not in hook or not hook['always_run']
|
||||||
|
|
||||||
if hook['id'] in skips:
|
if hook['id'] in skips:
|
||||||
_print_user_skipped(hook, write, args)
|
_print_user_skipped(hook, write, args)
|
||||||
return 0
|
return 0
|
||||||
elif not filenames:
|
elif compute_file_names:
|
||||||
_print_no_files_skipped(hook, write, args)
|
filenames = get_filenames(args, hook['files'], hook['exclude'])
|
||||||
return 0
|
if not filenames:
|
||||||
|
_print_no_files_skipped(hook, write, args)
|
||||||
|
return 0
|
||||||
|
|
||||||
# Print the hook and the dots first in case the hook takes hella long to
|
# Print the hook and the dots first in case the hook takes hella long to
|
||||||
# run.
|
# run.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue