-if "short" in argv:
- cmd.append("--abbrev=0")
-
-version: T.Optional[str] = None
-
-try:
- result = subp.run(cmd, stdout=subp.PIPE, encoding="utf-8", check=False)
- if not result.returncode:
- version = result.stdout
-except FileNotFoundError:
- pass
-
-if not version:
- try:
- with open(path.join(SOURCE_ROOT, "VERSION"), "r", encoding="utf-8") as f:
- version = f.read().strip()
- except OSError as e:
- print("could not read version from file", e, file=stderr)
-elif version.startswith(PREFIX):
- version = version[len(PREFIX) :].strip()
-
-print(version if version else "unknown", end="")
+result = subp.run(cmd, stdout=subp.PIPE, encoding="utf-8", check=True)
+version = result.stdout.strip().removeprefix("release-")
+print(version)