From 54ccb65a09ba613bef7272d808e748126d280f8a Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Wed, 8 Nov 2017 15:49:24 -0800 Subject: [PATCH 1/5] Add existing repo_config to output_repos --- pre_commit/commands/autoupdate.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index ca8f9bb1..08c694be 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -118,6 +118,7 @@ def autoupdate(runner, tags_only, repo=None): for repo_config in input_config['repos']: # Skip any repo_configs that aren't the specified repo if repo and repo != repo_config['repo']: + output_repos.append(repo_config) continue if is_local_repo(repo_config) or is_meta_repo(repo_config): From e4f28a2193a5b645cdffbfbc5adbe5cfdf53da01 Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Wed, 8 Nov 2017 15:53:01 -0800 Subject: [PATCH 2/5] Edit comment --- pre_commit/commands/autoupdate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index 08c694be..85ee2981 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -116,7 +116,7 @@ def autoupdate(runner, tags_only, repo=None): 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 + # Skip updating any repo_configs that aren't the specified repo if repo and repo != repo_config['repo']: output_repos.append(repo_config) continue From dfb058f15fd24b0670ffb5c868394cb3e9c6315d Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Wed, 8 Nov 2017 15:55:02 -0800 Subject: [PATCH 3/5] Edit comment again --- pre_commit/commands/autoupdate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index 85ee2981..d05269e9 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -116,7 +116,7 @@ def autoupdate(runner, tags_only, repo=None): input_config = load_config(runner.config_file_path) for repo_config in input_config['repos']: - # Skip updating any repo_configs that aren't the specified repo + # Skip updating any repo_configs that aren't for the specified repo if repo and repo != repo_config['repo']: output_repos.append(repo_config) continue From 090030447d42c0c6994a958b18c20976ac9b5b74 Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Wed, 8 Nov 2017 17:05:22 -0800 Subject: [PATCH 4/5] Combine blocks --- pre_commit/commands/autoupdate.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pre_commit/commands/autoupdate.py b/pre_commit/commands/autoupdate.py index d05269e9..5ba5a8eb 100644 --- a/pre_commit/commands/autoupdate.py +++ b/pre_commit/commands/autoupdate.py @@ -116,12 +116,12 @@ def autoupdate(runner, tags_only, repo=None): input_config = load_config(runner.config_file_path) for repo_config in input_config['repos']: - # Skip updating any repo_configs that aren't for the specified repo - if repo and repo != repo_config['repo']: - output_repos.append(repo_config) - continue - - if is_local_repo(repo_config) or is_meta_repo(repo_config): + if ( + is_local_repo(repo_config) or + is_meta_repo(repo_config) or + # Skip updating any repo_configs that aren't for the specified repo + repo and repo != repo_config['repo'] + ): output_repos.append(repo_config) continue output.write('Updating {}...'.format(repo_config['repo'])) From ab47d08a38c67d6e974295fb58af753b4e8930ad Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Wed, 8 Nov 2017 18:04:13 -0800 Subject: [PATCH 5/5] Make regression test that ensures autoupdate foo keeps everything else --- tests/commands/autoupdate_test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/commands/autoupdate_test.py b/tests/commands/autoupdate_test.py index c78af1fb..ee20c7dd 100644 --- a/tests/commands/autoupdate_test.py +++ b/tests/commands/autoupdate_test.py @@ -127,10 +127,12 @@ def test_autoupdate_out_of_date_repo( def test_autoupdate_out_of_date_repo_with_correct_repo_name( out_of_date_repo, in_tmpdir, mock_out_store_directory, ): - # Write out the config - config = make_config_from_repo( + stale_config = make_config_from_repo( out_of_date_repo.path, sha=out_of_date_repo.original_sha, check=False, ) + local_config = config_with_local_hooks() + config = {'repos': [stale_config, local_config]} + # Write out the config write_config('.', config) runner = Runner('.', C.CONFIG_FILE) @@ -141,6 +143,7 @@ def test_autoupdate_out_of_date_repo_with_correct_repo_name( assert ret == 0 assert before != after assert out_of_date_repo.head_sha in after + assert local_config['repo'] in after def test_autoupdate_out_of_date_repo_with_wrong_repo_name(