diff options
author | Jesús <heckyel@hyperbola.info> | 2021-08-11 11:14:54 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-08-11 11:14:54 -0500 |
commit | 97ca52e77a42b8117732e7ffc16f2c44984ae304 (patch) | |
tree | 3be11991455a031bdcc03386cdb24a556f664400 /youtube | |
parent | 16f81de96856b714b991e1db025d10fc9dfe5909 (diff) | |
download | yt-local-97ca52e77a42b8117732e7ffc16f2c44984ae304.tar.lz yt-local-97ca52e77a42b8117732e7ffc16f2c44984ae304.tar.xz yt-local-97ca52e77a42b8117732e7ffc16f2c44984ae304.zip |
[get_app_version]: check git command
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/get_app_version/get_app_version.py | 45 |
1 files changed, 24 insertions, 21 deletions
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 |