forked from It4innovations/hyperqueue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_docs_version.py
More file actions
34 lines (28 loc) · 881 Bytes
/
get_docs_version.py
File metadata and controls
34 lines (28 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
import subprocess
def latest_version():
return {"type": "latest"}
def get_version(output: str):
if not output:
return latest_version()
else:
tags = [
t.strip() for t in output.splitlines(keepends=False) if t.startswith("v")
]
# Ignore pre-release versions
tags = [tag for tag in tags if "-" not in tag]
if not tags:
return latest_version()
tags = sorted(tags)
tag = tags[0]
return {"type": "stable", "version": tag}
if __name__ == "__main__":
"""
Calculates whether the current commit is a stable version (=there is some tag pointing to it) or
an unstable one.
"""
output = (
subprocess.check_output(["git", "tag", "--points-at", "HEAD"]).decode().strip()
)
version = get_version(output)
print(json.dumps(version))