mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Make pre_commit also support pre-push hook
This commit is contained in:
parent
d2b11a0c50
commit
b707cbba06
10 changed files with 227 additions and 42 deletions
|
|
@ -44,8 +44,18 @@ def main(argv=None):
|
|||
'in the config file.'
|
||||
),
|
||||
)
|
||||
install_parser.add_argument(
|
||||
'-t', '--hook-type', choices=('pre-commit', 'pre-push'),
|
||||
default='pre-commit',
|
||||
)
|
||||
|
||||
subparsers.add_parser('uninstall', help='Uninstall the pre-commit script.')
|
||||
uninstall_parser = subparsers.add_parser(
|
||||
'uninstall', help='Uninstall the pre-commit script.',
|
||||
)
|
||||
uninstall_parser.add_argument(
|
||||
'-t', '--hook-type', choices=('pre-commit', 'pre-push'),
|
||||
default='pre-commit',
|
||||
)
|
||||
|
||||
subparsers.add_parser('clean', help='Clean out pre-commit files.')
|
||||
|
||||
|
|
@ -67,6 +77,15 @@ def main(argv=None):
|
|||
run_parser.add_argument(
|
||||
'--verbose', '-v', action='store_true', default=False,
|
||||
)
|
||||
|
||||
run_parser.add_argument(
|
||||
'--origin', '-o', default='',
|
||||
help='The origin branch"s commit_id when using `git push`',
|
||||
)
|
||||
run_parser.add_argument(
|
||||
'--source', '-s', default='',
|
||||
help='The remote branch"s commit_id when using `git push`',
|
||||
)
|
||||
run_mutex_group = run_parser.add_mutually_exclusive_group(required=False)
|
||||
run_mutex_group.add_argument(
|
||||
'--all-files', '-a', action='store_true', default=False,
|
||||
|
|
@ -98,9 +117,10 @@ def main(argv=None):
|
|||
if args.command == 'install':
|
||||
return install(
|
||||
runner, overwrite=args.overwrite, hooks=args.install_hooks,
|
||||
hook_type=args.hook_type,
|
||||
)
|
||||
elif args.command == 'uninstall':
|
||||
return uninstall(runner)
|
||||
return uninstall(runner, hook_type=args.hook_type)
|
||||
elif args.command == 'clean':
|
||||
return clean(runner)
|
||||
elif args.command == 'autoupdate':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue