MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / replace_workspace_package_version

Function replace_workspace_package_version

scripts/scripts/bump-version.py:81–89  ·  view source on GitHub ↗
(toml: str, new_version: str)

Source from the content-addressed store, hash-verified

79
80
81def 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
92def get_current_versions() -> dict:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected