0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-14 12:23:48 +01:00

Handle FileNotFound error in checking git repository version (#6284)

This commit is contained in:
Andrew Morgan 2019-10-30 11:00:15 +00:00 committed by GitHub
parent 770d1ef673
commit b39ca49db1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

1
changelog.d/6284.bugfix Normal file
View file

@ -0,0 +1 @@
Prevent errors from appearing on Synapse startup if `git` is not installed.

View file

@ -42,6 +42,7 @@ def get_version_string(module):
try: try:
null = open(os.devnull, "w") null = open(os.devnull, "w")
cwd = os.path.dirname(os.path.abspath(module.__file__)) cwd = os.path.dirname(os.path.abspath(module.__file__))
try: try:
git_branch = ( git_branch = (
subprocess.check_output( subprocess.check_output(
@ -51,7 +52,8 @@ def get_version_string(module):
.decode("ascii") .decode("ascii")
) )
git_branch = "b=" + git_branch git_branch = "b=" + git_branch
except subprocess.CalledProcessError: except (subprocess.CalledProcessError, FileNotFoundError):
# FileNotFoundError can arise when git is not installed
git_branch = "" git_branch = ""
try: try:
@ -63,7 +65,7 @@ def get_version_string(module):
.decode("ascii") .decode("ascii")
) )
git_tag = "t=" + git_tag git_tag = "t=" + git_tag
except subprocess.CalledProcessError: except (subprocess.CalledProcessError, FileNotFoundError):
git_tag = "" git_tag = ""
try: try:
@ -74,7 +76,7 @@ def get_version_string(module):
.strip() .strip()
.decode("ascii") .decode("ascii")
) )
except subprocess.CalledProcessError: except (subprocess.CalledProcessError, FileNotFoundError):
git_commit = "" git_commit = ""
try: try:
@ -89,7 +91,7 @@ def get_version_string(module):
) )
git_dirty = "dirty" if is_dirty else "" git_dirty = "dirty" if is_dirty else ""
except subprocess.CalledProcessError: except (subprocess.CalledProcessError, FileNotFoundError):
git_dirty = "" git_dirty = ""
if git_branch or git_tag or git_commit or git_dirty: if git_branch or git_tag or git_commit or git_dirty: