Skip to content

Commit 86da772

Browse files
authored
Merge pull request pre-commit#713 from pre-commit/update_many_repos
Allow autoupdate --repo to be specified multiple times
2 parents 082c950 + f76d3c4 commit 86da772

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

pre_commit/commands/autoupdate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _write_new_config_file(path, output):
106106
f.write(to_write)
107107

108108

109-
def autoupdate(runner, tags_only, repo=None):
109+
def autoupdate(runner, tags_only, repos=()):
110110
"""Auto-update the pre-commit config to the latest versions of repos."""
111111
migrate_config(runner, quiet=True)
112112
retv = 0
@@ -120,7 +120,7 @@ def autoupdate(runner, tags_only, repo=None):
120120
is_local_repo(repo_config) or
121121
is_meta_repo(repo_config) or
122122
# Skip updating any repo_configs that aren't for the specified repo
123-
repo and repo != repo_config['repo']
123+
repos and repo_config['repo'] not in repos
124124
):
125125
output_repos.append(repo_config)
126126
continue

pre_commit/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ def main(argv=None):
168168
),
169169
)
170170
autoupdate_parser.add_argument(
171-
'--repo', help='Only update this repository.',
171+
'--repo', dest='repos', action='append', metavar='REPO',
172+
help='Only update this repository -- may be specified multiple times.',
172173
)
173174

174175
migrate_config_parser = subparsers.add_parser(
@@ -251,7 +252,7 @@ def main(argv=None):
251252
return autoupdate(
252253
runner,
253254
tags_only=not args.bleeding_edge,
254-
repo=args.repo,
255+
repos=args.repos,
255256
)
256257
elif args.command == 'migrate-config':
257258
return migrate_config(runner)

tests/commands/autoupdate_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_autoupdate_out_of_date_repo_with_correct_repo_name(
138138
runner = Runner('.', C.CONFIG_FILE)
139139
before = open(C.CONFIG_FILE).read()
140140
repo_name = 'file://{}'.format(out_of_date_repo.path)
141-
ret = autoupdate(runner, tags_only=False, repo=repo_name)
141+
ret = autoupdate(runner, tags_only=False, repos=(repo_name,))
142142
after = open(C.CONFIG_FILE).read()
143143
assert ret == 0
144144
assert before != after
@@ -158,7 +158,7 @@ def test_autoupdate_out_of_date_repo_with_wrong_repo_name(
158158
runner = Runner('.', C.CONFIG_FILE)
159159
before = open(C.CONFIG_FILE).read()
160160
# It will not update it, because the name doesn't match
161-
ret = autoupdate(runner, tags_only=False, repo='wrong_repo_name')
161+
ret = autoupdate(runner, tags_only=False, repos=('wrong_repo_name',))
162162
after = open(C.CONFIG_FILE).read()
163163
assert ret == 0
164164
assert before == after

0 commit comments

Comments
 (0)