(toml: str, new_version: str)
| 79 | |
| 80 | |
| 81 | def replace_workspace_package_version(toml: str, new_version: str) -> tuple[str, bool]: |
| 82 | pattern = re.compile( |
| 83 | r'(\n\[workspace\.package\][\s\S]*?\n)(version\s*=\s*\")([^\"]+)(\"\s*)(\n)', |
| 84 | re.MULTILINE, |
| 85 | ) |
| 86 | def _repl(m: re.Match) -> str: |
| 87 | return f"{m.group(1)}{m.group(2)}{new_version}{m.group(4)}{m.group(5)}" |
| 88 | new_toml, n = pattern.subn(_repl, toml, count=1) |
| 89 | return new_toml, n > 0 |
| 90 | |
| 91 | |
| 92 | def get_current_versions() -> dict: |