use check_output for git describe execution and define fallback VERSION earlier
This commit is contained in:
parent
b41d80075a
commit
e55db1b427
1 changed files with 9 additions and 11 deletions
|
@ -27,23 +27,21 @@ import subprocess
|
||||||
import cdist.log
|
import cdist.log
|
||||||
|
|
||||||
|
|
||||||
|
VERSION = 'unknown version'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import cdist.version
|
import cdist.version
|
||||||
VERSION = cdist.version.VERSION
|
VERSION = cdist.version.VERSION
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
cdist_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
cdist_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
||||||
if os.path.isdir(os.path.join(cdist_dir, '.git')):
|
if os.path.isdir(os.path.join(cdist_dir, '.git')):
|
||||||
run_git = subprocess.run(
|
try:
|
||||||
|
VERSION = subprocess.check_output(
|
||||||
['git', 'describe', '--always'],
|
['git', 'describe', '--always'],
|
||||||
cwd=cdist_dir,
|
cwd=cdist_dir,
|
||||||
capture_output=True,
|
universal_newlines=True)
|
||||||
text=True)
|
except:
|
||||||
if run_git.returncode == 0:
|
pass
|
||||||
VERSION = run_git.stdout
|
|
||||||
else:
|
|
||||||
VERSION = 'from git'
|
|
||||||
else:
|
|
||||||
VERSION = 'unknown version'
|
|
||||||
|
|
||||||
BANNER = """
|
BANNER = """
|
||||||
.. . .x+=:. s
|
.. . .x+=:. s
|
||||||
|
|
Loading…
Reference in a new issue