-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathenviron.py
More file actions
34 lines (26 loc) · 732 Bytes
/
environ.py
File metadata and controls
34 lines (26 loc) · 732 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
#
# SPDX-License-Identifier: AGPL-3.0-or-later
#
import os.path
import subprocess
ci: bool = os.environ.get('CI', 'false').lower() == 'true'
production: bool = int(os.environ.get('PRODUCTION', '0')) != 0
def get_version() -> str:
try:
version = subprocess.check_output([
'git',
'-C', os.path.dirname(__file__),
'show',
'-s',
'--date=format:%Y-%m-%d',
'--format=%h (%cd)',
'HEAD',
], text=True)
except (FileNotFoundError, subprocess.CalledProcessError):
if ci:
raise
else:
version = 'unknown'
else:
version = version.rstrip()
return version