FiraCode/script/version.py

18 wiersze
573 B
Python
Executable File
Czysty Wina Historia

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#! /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)