INNER CODE UNIT · Python

parse_tag

sun-jiao/flut-renamer · packaging/release_version.py:8

def parse_tag(tag):
    match = re.fullmatch(
        r'v([0-9]+\.[0-9]+\.[0-9]+)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?',
        tag,
    )
    if not match:
        raise ValueError('Release tags must use vX.Y.Z or vX.Y.Z-suffix')
    return match[1], tag[1:]


def validate_version(tag, pubspec):
    base, _ = parse_tag(tag)
    match = re.search(r'^version:\s*([0-9]+\.[0-9]+\.[0-9]+)(?:\+[0-9]+)?\s*$',
                      pubspec, re.MULTILINE)
    if not match:
        raise ValueError('Cannot read the version from pubspec.yaml')
    if base != match[1]:
        raise ValueError(f'Tag base version {base} does not match pubspec.yaml version {match[1]}')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…