INNER CODE UNIT · Python
write_pubspec_version
fluxerapp/flutter_client · .github/scripts/app_version.py:65
def write_pubspec_version(version: AppVersion, path: Path = PUBSPEC_PATH) -> None:
lines = path.read_text(encoding="utf-8").splitlines(keepends=True)
replaced = False
for index, raw_line in enumerate(lines):
stripped = raw_line.rstrip("\r\n")
newline = raw_line[len(stripped) :]
match = VERSION_LINE_PATTERN.match(stripped)
if match is None:
continue
lines[index] = f"{match.group(1)}{version.pubspec_value}{newline}"
replaced = True
break
if not replaced:
raise ValueError(f"Could not find version in {path}")
path.write_text("".join(lines), encoding="utf-8")
def calendar_version_for(now: datetime, current: AppVersion) -> AppVersion: