From 97ca52e77a42b8117732e7ffc16f2c44984ae304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Wed, 11 Aug 2021 11:14:54 -0500 Subject: [get_app_version]: check git command --- youtube/get_app_version/get_app_version.py | 45 ++++++++++++++++-------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'youtube') diff --git a/youtube/get_app_version/get_app_version.py b/youtube/get_app_version/get_app_version.py index 51eb2ce..9852359 100644 --- a/youtube/get_app_version/get_app_version.py +++ b/youtube/get_app_version/get_app_version.py @@ -24,28 +24,31 @@ def app_version(): cmd, stdout=subprocess.PIPE, env=env).communicate()[0] return out - if call(["git", "branch"], stderr=STDOUT, - stdout=open(os.devnull, 'w')) != 0: - - subst_list = { - "version": __version__, - "branch": None, - "commit": None - } - + subst_list = { + "version": __version__, + "branch": None, + "commit": None + } + + if os.system("command -v git > /dev/null 2>&1") != 0: + subst_list else: - # version - 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 = { - "version": __version__, - "branch": git_branch, - "commit": git_revision - } + if call(["git", "branch"], stderr=STDOUT, + stdout=open(os.devnull, 'w')) != 0: + subst_list + else: + # version + 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 = { + "version": __version__, + "branch": git_branch, + "commit": git_revision + } return subst_list -- cgit v1.2.3