[get_app_version]: check git command
This commit is contained in:
parent
16f81de968
commit
97ca52e77a
@ -24,28 +24,31 @@ def app_version():
|
|||||||
cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
|
cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
|
||||||
return out
|
return out
|
||||||
|
|
||||||
if call(["git", "branch"], stderr=STDOUT,
|
subst_list = {
|
||||||
stdout=open(os.devnull, 'w')) != 0:
|
"version": __version__,
|
||||||
|
"branch": None,
|
||||||
subst_list = {
|
"commit": None
|
||||||
"version": __version__,
|
}
|
||||||
"branch": None,
|
|
||||||
"commit": None
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if os.system("command -v git > /dev/null 2>&1") != 0:
|
||||||
|
subst_list
|
||||||
else:
|
else:
|
||||||
# version
|
if call(["git", "branch"], stderr=STDOUT,
|
||||||
describe = minimal_env_cmd(["git", "describe", "--always"])
|
stdout=open(os.devnull, 'w')) != 0:
|
||||||
git_revision = describe.strip().decode('ascii')
|
subst_list
|
||||||
# branch
|
else:
|
||||||
branch = minimal_env_cmd(["git", "branch"])
|
# version
|
||||||
git_branch = branch.strip().decode('ascii').replace('* ', '')
|
describe = minimal_env_cmd(["git", "describe", "--always"])
|
||||||
|
git_revision = describe.strip().decode('ascii')
|
||||||
|
# branch
|
||||||
|
branch = minimal_env_cmd(["git", "branch"])
|
||||||
|
git_branch = branch.strip().decode('ascii').replace('* ', '')
|
||||||
|
|
||||||
subst_list = {
|
subst_list = {
|
||||||
"version": __version__,
|
"version": __version__,
|
||||||
"branch": git_branch,
|
"branch": git_branch,
|
||||||
"commit": git_revision
|
"commit": git_revision
|
||||||
}
|
}
|
||||||
|
|
||||||
return subst_list
|
return subst_list
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user