feat: Skip autoupdate · pre-commit/pre-commit@54b262b · GitHub
Skip to content

Commit 54b262b

Browse files
author
Oleg Shatov
committed
feat: Skip autoupdate
1 parent 805f335 commit 54b262b

4 files changed

Lines changed: 88 additions & 2 deletions

File tree

pre_commit/clientlib.py

Lines changed: 5 additions & 1 deletion

pre_commit/commands/autoupdate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ def autoupdate(
187187
i, repo, tags_only=tags_only, freeze=freeze,
188188
)
189189
for i, repo in enumerate(config_repos)
190-
if not repos or repo['repo'] in repos
190+
if repo['repo'] in repos or (
191+
not repos and not repo.get('skip_autoupdate', False)
192+
)
191193
]
192194
for future in concurrent.futures.as_completed(futures):
193195
try:

tests/clientlib_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ def test_check_type_tag_success():
6464
],
6565
}],
6666
},
67+
{
68+
'repos': [{
69+
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
70+
'rev': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
71+
'skip_autoupdate': True,
72+
'hooks': [{'id': 'pyflakes'}],
73+
}],
74+
},
6775
),
6876
)
6977
def test_config_valid(cfg):
@@ -89,6 +97,18 @@ def test_invalid_config_wrong_type():
8997
assert not is_valid_according_to_schema(cfg, CONFIG_SCHEMA)
9098

9199

100+
def test_skip_autoupdate_must_be_bool():
101+
cfg = {
102+
'repos': [{
103+
'repo': 'git@github.com:pre-commit/pre-commit-hooks',
104+
'rev': 'cd74dc150c142c3be70b24eaf0b02cae9d235f37',
105+
'skip_autoupdate': 'true',
106+
'hooks': [{'id': 'pyflakes'}],
107+
}],
108+
}
109+
assert not is_valid_according_to_schema(cfg, CONFIG_SCHEMA)
110+
111+
92112
def test_local_hooks_with_rev_fails():
93113
config_obj = {'repos': [dict(sample_local_config(), rev='foo')]}
94114
with pytest.raises(cfgv.ValidationError):

tests/commands/autoupdate_test.py

Lines changed: 60 additions & 0 deletions

0 commit comments

Comments
 (0)