diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index aa0c5e25e..f5e943aa7 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -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 diff --git a/tests/commands/autoupdate_test.py b/tests/commands/autoupdate_test.py index 71bd04446..1b9ecf220 100644 --- a/tests/commands/autoupdate_test.py +++ b/tests/commands/autoupdate_test.py @@ -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( @@ -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