2017-11-16 19:51:44 +01:00
|
|
|
# System documented in https://zulip.readthedocs.io/en/latest/subsystems/logging.html
|
2017-12-01 01:54:24 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
2023-06-10 01:01:05 +02:00
|
|
|
from typing import Optional
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2017-12-01 01:54:24 +01:00
|
|
|
|
|
|
|
def try_git_describe() -> Optional[str]:
|
2018-03-11 17:29:38 +01:00
|
|
|
try: # nocoverage
|
2017-12-01 01:54:24 +01:00
|
|
|
return subprocess.check_output(
|
2021-02-12 08:20:45 +01:00
|
|
|
["git", "describe", "--tags", "--match=[0-9]*", "--always", "--dirty", "--long"],
|
2017-12-01 01:54:24 +01:00
|
|
|
stderr=subprocess.PIPE,
|
2021-02-12 08:20:45 +01:00
|
|
|
cwd=os.path.join(os.path.dirname(__file__), ".."),
|
2022-01-22 07:52:54 +01:00
|
|
|
text=True,
|
2020-10-30 01:36:18 +01:00
|
|
|
).strip()
|
2020-10-09 03:32:00 +02:00
|
|
|
except (FileNotFoundError, subprocess.CalledProcessError): # nocoverage
|
2017-12-01 01:54:24 +01:00
|
|
|
return None
|