1
0
Fork 0
mirror of synced 2024-05-02 03:33:05 +12:00
FiraCode/script/version.py

18 lines
573 B
Python
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#! /usr/bin/env python3
import os, re, subprocess, sys
def revision():
os.chdir(os.path.abspath(os.path.dirname(__file__) + '/..'))
desc = subprocess.check_output(["git", "describe", "--tags"], cwd = os.path.dirname(__file__)).decode("utf-8")
match = re.match("([0-9.]+)-([0-9]+)-[a-z0-9]+", desc)
if match:
return match.group(1) + "." + match.group(2)
match = re.match("([0-9]+.[0-9]+).0", desc)
if match:
return match.group(1) + ".0"
raise Exception("Cant parse revision: " + desc)
if __name__ == '__main__':
print(revision())
sys.exit(0)