Files
cutdex/tool/windows/update_versions.py

19 lines
704 B
Python

"""Windows update version ordering, independent of Flutter package resolution."""
import re
def update_version(display_version, build):
version = display_version + '-build.' + str(int(build))
numeric_version(version)
return version
def numeric_version(version):
number = r'(0|[1-9]\d*)'
match = re.fullmatch(rf'{number}\.{number}\.{number}(?:-build\.{number})?', version)
if not match:
raise ValueError('Windows update versions must use major.minor.patch-build.number')
major, minor, patch, build = match.groups()
# SemVer +build metadata does not participate in precedence.
return (int(major), int(minor), int(patch), int(build is None), int(build or 0))