This commit is contained in:
Ben Norquist 2019-04-30 17:42:40 -07:00
parent 195c406b78
commit fa92aa223f
4 changed files with 37 additions and 6 deletions

View file

@ -36,7 +36,9 @@ repos:
rev: v1.0.0 rev: v1.0.0
hooks: hooks:
- id: add-trailing-comma - id: add-trailing-comma
- repo: meta - repo: meta
hooks: hooks:
- id: check-hooks-apply - id: check-hooks-apply
- id: check-useless-excludes - id: check-useless-excludes
- id: identity
- id: sign-commit

View file

@ -166,6 +166,13 @@ _meta = (
('entry', _entry('identity')), ('entry', _entry('identity')),
), ),
), ),
(
'sign-commit', (
('name', 'identity'),
('verbose', True),
('entry', _entry('identity')),
),
),
) )
META_HOOK_DICT = cfgv.Map( META_HOOK_DICT = cfgv.Map(

View file

@ -73,7 +73,7 @@ SKIPPED = 'Skipped'
NO_FILES = '(no files to check)' NO_FILES = '(no files to check)'
def _run_single_hook(classifier, hook, args, skips, cols): def _run_single_hook(classifier, hook, args, skips, cols, retval):
filenames = classifier.filenames_for_hook(hook) filenames = classifier.filenames_for_hook(hook)
if hook.language == 'pcre': if hook.language == 'pcre':
@ -211,7 +211,8 @@ def _run_hooks(config, hooks, args, environ):
classifier = Classifier(filenames) classifier = Classifier(filenames)
retval = 0 retval = 0
for hook in hooks: for hook in hooks:
retval |= _run_single_hook(classifier, hook, args, skips, cols) args
retval |= _run_single_hook(classifier, hook, args, skips, cols, retval)
if retval and config['fail_fast']: if retval and config['fail_fast']:
break break
if retval and args.show_diff_on_failure and git.has_diff(): if retval and args.show_diff_on_failure and git.has_diff():

View file

@ -0,0 +1,21 @@
import argparse
from pre_commit import output
def sign_commit():
pass
def main(argv=None):
parser = argparse.ArgumentParser()
parser.add_argument('retval', nargs='*', default=0)
args = parser.parse_args(argv)
output.write_line(f'Signing commit message if {args.retval}')
if args.retval:
return 1
return 0
if __name__ == '__main__':
exit(main())