brintos

brintos / llvm-project-archived public Read only

0
0
Text · 874 B · f75fd50 Raw
37 lines · python
1#!/usr/bin/python32 3from git import Repo4import re5import sys6 7 8def get_version_from_tag(tag):9    m = re.match("llvmorg-([0-9]+)\.([0-9]+)\.([0-9]+)(-rc[0-9]+)?$", tag)10    if m:11        if m.lastindex == 4:12            # We have an rc tag.13            return m.group(1, 2, 3)14        # We have a final release tag.15        return (m.group(1), m.group(2), str(int(m.group(3)) + 1))16 17    m = re.match("llvmorg-([0-9]+)-init", tag)18    if m:19        return (m.group(1), "1", "0")20 21    raise Exception(f"error: Tag is not valid: {tag}")22 23 24version = sys.argv[1]25 26repo = Repo()27 28tag = repo.git.describe(tags=True, abbrev=0)29expected_version = ".".join(get_version_from_tag(tag))30 31if version != expected_version:32    print("error: Expected version", expected_version, "but found version", version)33    sys.exit(1)34 35print("Versions match:", version, expected_version)36sys.exit(0)37