Extract release version number from tag, if applicable
This commit is contained in:
@@ -30,3 +30,19 @@ def git_date(short=True):
|
||||
return iso
|
||||
except Exception:
|
||||
raise RuntimeError("Could not read git commit date. Make sure you have git installed and you're working with a git clone of the repository.")
|
||||
|
||||
def git_release_version(search_prefix):
|
||||
try:
|
||||
tags = subprocess.check_output([
|
||||
'git',
|
||||
'tag',
|
||||
'--points-at',
|
||||
'HEAD',
|
||||
]).decode('utf-8').splitlines()
|
||||
for tag in tags:
|
||||
if tag.startswith(search_prefix):
|
||||
return tag[len(search_prefix):]
|
||||
return None
|
||||
except Exception:
|
||||
raise RuntimeError("Could not read git release tags. Make sure you have git installed and you're working with a git clone of the repository.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user