mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-25 18:39:16 -06:00
Add repo option to autoupdate
This commit is contained in:
@@ -106,7 +106,7 @@ def _write_new_config_file(path, output):
|
||||
f.write(to_write)
|
||||
|
||||
|
||||
def autoupdate(runner, tags_only):
|
||||
def autoupdate(runner, tags_only, repo=None):
|
||||
"""Auto-update the pre-commit config to the latest versions of repos."""
|
||||
migrate_config(runner, quiet=True)
|
||||
retv = 0
|
||||
@@ -116,6 +116,10 @@ def autoupdate(runner, tags_only):
|
||||
input_config = load_config(runner.config_file_path)
|
||||
|
||||
for repo_config in input_config['repos']:
|
||||
# Skip any repo_configs that aren't the specified repo
|
||||
if repo and repo != repo_config['repo']:
|
||||
continue
|
||||
|
||||
if is_local_repo(repo_config) or is_meta_repo(repo_config):
|
||||
output_repos.append(repo_config)
|
||||
continue
|
||||
|
||||
@@ -167,6 +167,12 @@ def main(argv=None):
|
||||
'tagged version (the default behavior).'
|
||||
),
|
||||
)
|
||||
autoupdate_parser.add_argument(
|
||||
'--repo', nargs=1, default=None,
|
||||
help=(
|
||||
'Repository to update the hooks of.'
|
||||
),
|
||||
)
|
||||
|
||||
migrate_config_parser = subparsers.add_parser(
|
||||
'migrate-config',
|
||||
@@ -245,7 +251,11 @@ def main(argv=None):
|
||||
elif args.command == 'autoupdate':
|
||||
if args.tags_only:
|
||||
logger.warning('--tags-only is the default')
|
||||
return autoupdate(runner, tags_only=not args.bleeding_edge)
|
||||
return autoupdate(
|
||||
runner,
|
||||
tags_only=not args.bleeding_edge,
|
||||
repo=args.repo,
|
||||
)
|
||||
elif args.command == 'migrate-config':
|
||||
return migrate_config(runner)
|
||||
elif args.command == 'run':
|
||||
|
||||
Reference in New Issue
Block a user