1#!/usr/bin/env python3
2
3import re
4import sys
5import subprocess
6
7try:
8  version = subprocess.check_output(
9    ['git', 'describe', '--all', '--long', '--dirty'],
10    stderr=subprocess.DEVNULL
11  )
12except:
13  sys.exit(1)
14
15version = str(version, encoding='UTF-8').strip()
16print(re.sub(r'^heads\/(.*)-0-(g.*)$', r'\1~\2', version))
17