mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Merge pull request #1263 from pre-commit/clear_frozen
clear 'frozen: ...' comment if autoupdate unfreezes
This commit is contained in:
commit
f5e7337db6
2 changed files with 9 additions and 2 deletions
|
|
@ -108,7 +108,9 @@ def _write_new_config(path, rev_infos):
|
||||||
new_rev_s = ordered_dump({'rev': rev_info.rev}, **C.YAML_DUMP_KWARGS)
|
new_rev_s = ordered_dump({'rev': rev_info.rev}, **C.YAML_DUMP_KWARGS)
|
||||||
new_rev = new_rev_s.split(':', 1)[1].strip()
|
new_rev = new_rev_s.split(':', 1)[1].strip()
|
||||||
if rev_info.frozen is not None:
|
if rev_info.frozen is not None:
|
||||||
comment = ' # {}'.format(rev_info.frozen)
|
comment = ' # frozen: {}'.format(rev_info.frozen)
|
||||||
|
elif match.group(4).strip().startswith('# frozen:'):
|
||||||
|
comment = ''
|
||||||
else:
|
else:
|
||||||
comment = match.group(4)
|
comment = match.group(4)
|
||||||
lines[idx] = REV_LINE_FMT.format(
|
lines[idx] = REV_LINE_FMT.format(
|
||||||
|
|
|
||||||
|
|
@ -312,9 +312,14 @@ def test_autoupdate_freeze(tagged, in_tmpdir, store):
|
||||||
|
|
||||||
assert autoupdate(C.CONFIG_FILE, store, freeze=True, tags_only=False) == 0
|
assert autoupdate(C.CONFIG_FILE, store, freeze=True, tags_only=False) == 0
|
||||||
with open(C.CONFIG_FILE) as f:
|
with open(C.CONFIG_FILE) as f:
|
||||||
expected = 'rev: {} # v1.2.3'.format(tagged.head_rev)
|
expected = 'rev: {} # frozen: v1.2.3'.format(tagged.head_rev)
|
||||||
assert expected in f.read()
|
assert expected in f.read()
|
||||||
|
|
||||||
|
# if we un-freeze it should remove the frozen comment
|
||||||
|
assert autoupdate(C.CONFIG_FILE, store, freeze=False, tags_only=False) == 0
|
||||||
|
with open(C.CONFIG_FILE) as f:
|
||||||
|
assert 'rev: v1.2.3\n' in f.read()
|
||||||
|
|
||||||
|
|
||||||
def test_autoupdate_tags_only(tagged, in_tmpdir, store):
|
def test_autoupdate_tags_only(tagged, in_tmpdir, store):
|
||||||
# add some commits after the tag
|
# add some commits after the tag
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue