(path: str, rev_infos: list[RevInfo | None])
| 138 | |
| 139 | |
| 140 | def _write_new_config(path: str, rev_infos: list[RevInfo | None]) -> None: |
| 141 | lines, idxs = _original_lines(path, rev_infos) |
| 142 | |
| 143 | for idx, rev_info in zip(idxs, rev_infos): |
| 144 | if rev_info is None: |
| 145 | continue |
| 146 | match = REV_LINE_RE.match(lines[idx]) |
| 147 | assert match is not None |
| 148 | new_rev_s = yaml_dump({'rev': rev_info.rev}, default_style=match[3]) |
| 149 | new_rev = new_rev_s.split(':', 1)[1].strip() |
| 150 | if rev_info.frozen is not None: |
| 151 | comment = f' # frozen: {rev_info.frozen}' |
| 152 | elif match[5].strip().startswith('# frozen:'): |
| 153 | comment = '' |
| 154 | else: |
| 155 | comment = match[5] |
| 156 | lines[idx] = f'{match[1]}rev:{match[2]}{new_rev}{comment}{match[6]}' |
| 157 | |
| 158 | with open(path, 'w', newline='') as f: |
| 159 | f.write(''.join(lines)) |
| 160 | |
| 161 | |
| 162 | def autoupdate( |
no test coverage detected