pre-commit gc

This commit is contained in:
Anthony Sottile 2019-01-01 22:01:10 -08:00
parent d7f5c6f979
commit 9e34e6e316
12 changed files with 412 additions and 116 deletions

View file

@ -11,6 +11,7 @@ from pre_commit import five
from pre_commit import git
from pre_commit.commands.autoupdate import autoupdate
from pre_commit.commands.clean import clean
from pre_commit.commands.gc import gc
from pre_commit.commands.install_uninstall import install
from pre_commit.commands.install_uninstall import install_hooks
from pre_commit.commands.install_uninstall import uninstall
@ -176,6 +177,11 @@ def main(argv=None):
)
_add_color_option(clean_parser)
_add_config_option(clean_parser)
gc_parser = subparsers.add_parser('gc', help='Clean unused cached repos.')
_add_color_option(gc_parser)
_add_config_option(gc_parser)
autoupdate_parser = subparsers.add_parser(
'autoupdate',
help="Auto-update pre-commit config to the latest repos' versions.",
@ -251,9 +257,11 @@ def main(argv=None):
with error_handler(), logging_handler(args.color):
_adjust_args_and_chdir(args)
store = Store()
git.check_for_cygwin_mismatch()
store = Store()
store.mark_config_used(args.config)
if args.command == 'install':
return install(
args.config, store,
@ -267,6 +275,8 @@ def main(argv=None):
return uninstall(hook_type=args.hook_type)
elif args.command == 'clean':
return clean(store)
elif args.command == 'gc':
return gc(store)
elif args.command == 'autoupdate':
if args.tags_only:
logger.warning('--tags-only is the default')