Commit aa168305 authored by Kyle Sunden's avatar Kyle Sunden
Browse files

Merge branch 'version' into 'master'

Update __version__.py

See merge request !14
parents 2a4161e0 5f8377e7
Pipeline #163357738 failed with stage
in 1 minute and 22 seconds
......@@ -2,6 +2,7 @@
import pathlib
import subprocess
here = pathlib.Path(__file__).resolve().parent
......@@ -14,16 +15,14 @@ __all__ = ["__version__", "__branch__"]
with open(str(here / "VERSION")) as f:
__version__ = f.read().strip()
try:
__branch__ = (
subprocess.run(["git", "branch", "--show-current"], capture_output=True, cwd=here)
.stdout.strip()
.decode()
)
except:
__branch__ = ""
# add git branch, if appropriate
p = here.parent / ".git"
if p.is_file():
with open(str(p)) as f:
p = p.parent / f.readline()[8:].strip() # Strip "gitdir: "
p = p / "HEAD"
if p.exists():
with open(str(p)) as f:
__branch__ = f.readline().rstrip().split(r"/")[-1]
if __branch__:
__version__ += "+" + __branch__
else:
__branch__ = ""
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment