Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pre_commit/commands/autoupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ def autoupdate(
repo for repo in load_config(config_file)['repos']
if repo['repo'] not in {LOCAL, META}
]
missing_repos = set(repos) - {r['repo'] for r in config_repos}
if missing_repos:
output.write_line(
f'repos {", ".join(sorted(missing_repos))!r} were '
f'not found in {config_file}',
)
return 1

rev_infos: list[RevInfo | None] = [None] * len(config_repos)
jobs = jobs or xargs.cpu_count() # 0 => number of cpus
Expand Down
7 changes: 3 additions & 4 deletions tests/commands/autoupdate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_autoupdate_out_of_date_repo_with_correct_repo_name(
assert 'local' in after


def test_autoupdate_out_of_date_repo_with_wrong_repo_name(
def test_autoupdate_missing_repo_name(
out_of_date, in_tmpdir,
):
config = make_config_from_repo(
Expand All @@ -270,14 +270,13 @@ def test_autoupdate_out_of_date_repo_with_wrong_repo_name(

with open(C.CONFIG_FILE) as f:
before = f.read()
# It will not update it, because the name doesn't match
ret = autoupdate(
C.CONFIG_FILE, freeze=False, tags_only=False,
repos=('dne',),
repos=('dne', 'foo'),
)
with open(C.CONFIG_FILE) as f:
after = f.read()
assert ret == 0
assert ret == 1
assert before == after


Expand Down
Loading