Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb2ced7

Browse files
authored
Merge pull request #661 from KevinHock/master
[Fix] Add existing repo_config to output_repos
2 parents dc6b9ee + ab47d08 commit bb2ced7

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

pre_commit/commands/autoupdate.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ def autoupdate(runner, tags_only, repo=None):
116116
input_config = load_config(runner.config_file_path)
117117

118118
for repo_config in input_config['repos']:
119-
# Skip any repo_configs that aren't the specified repo
120-
if repo and repo != repo_config['repo']:
121-
continue
122-
123-
if is_local_repo(repo_config) or is_meta_repo(repo_config):
119+
if (
120+
is_local_repo(repo_config) or
121+
is_meta_repo(repo_config) or
122+
# Skip updating any repo_configs that aren't for the specified repo
123+
repo and repo != repo_config['repo']
124+
):
124125
output_repos.append(repo_config)
125126
continue
126127
output.write('Updating {}...'.format(repo_config['repo']))

tests/commands/autoupdate_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ def test_autoupdate_out_of_date_repo(
127127
def test_autoupdate_out_of_date_repo_with_correct_repo_name(
128128
out_of_date_repo, in_tmpdir, mock_out_store_directory,
129129
):
130-
# Write out the config
131-
config = make_config_from_repo(
130+
stale_config = make_config_from_repo(
132131
out_of_date_repo.path, sha=out_of_date_repo.original_sha, check=False,
133132
)
133+
local_config = config_with_local_hooks()
134+
config = {'repos': [stale_config, local_config]}
135+
# Write out the config
134136
write_config('.', config)
135137

136138
runner = Runner('.', C.CONFIG_FILE)
@@ -141,6 +143,7 @@ def test_autoupdate_out_of_date_repo_with_correct_repo_name(
141143
assert ret == 0
142144
assert before != after
143145
assert out_of_date_repo.head_sha in after
146+
assert local_config['repo'] in after
144147

145148

146149
def test_autoupdate_out_of_date_repo_with_wrong_repo_name(

0 commit comments

Comments
 (0)