Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Handle FileNotFound error in checking git repository version #6284

Merged
merged 2 commits into from
Oct 30, 2019

Conversation

anoadragon453
Copy link
Member

@anoadragon453 anoadragon453 commented Oct 29, 2019

A user hit an interesting edge case where they'd get an error if git was not installed: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240498#c3

2019-09-11 14:43:53,745 - synapse.util.versionstring - 85 - INFO - None - Failed to check for git repository: [Errno 2] No such file or directory: 'git': 'git'

Just assume no git branch (does the same as if we weren't in a git directory) on FileNotFoundError, which not having git installed will produce:

✗ python3                                                                   
Python 3.6.8 (default, Jun 20 2019, 17:11:57) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.check_output(["git", "diff"])
b'diff --git a/scripts-dev/update_database b/scripts-dev/update_database\nindex 10166583e..27a1ad1e7 100755\n--- a/scripts-dev/update_database\n+++ b/scripts-dev/update_database\n@@ -25,8 +25,8 @@ from twisted.internet import defer, reactor\n from synapse.config.homeserver import HomeServerConfig\n from synapse.metrics.background_process_metrics import run_as_background_process\n from synapse.server import HomeServer\n-from synapse.storage.engines import create_engine\n from synapse.storage import DataStore\n+from synapse.storage.engines import create_engine\n from synapse.storage.prepare_database import prepare_database\n \n logger = logging.getLogger("update_database")\n@@ -122,4 +122,3 @@ if __name__ == "__main__":\n     ))\n \n     reactor.run()\n-\n'
>>> subprocess.check_output(["gitx", "diff"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/home/user/.pyenv/versions/3.6.8/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gitx': 'gitx'
>>> 

@anoadragon453 anoadragon453 self-assigned this Oct 29, 2019
@anoadragon453 anoadragon453 requested a review from a team October 30, 2019 10:01
@anoadragon453 anoadragon453 merged commit b39ca49 into develop Oct 30, 2019
@anoadragon453 anoadragon453 deleted the anoa/git_version_checking branch October 30, 2019 11:00
anoadragon453 added a commit that referenced this pull request Oct 30, 2019
…ger_warning

* 'develop' of github.com:matrix-org/synapse:
  Fix log line that was printing undefined value (#6278)
  Update CI to run isort on scripts and scripts-dev (#6270)
  Fix small typo in comment (#6269)
  Fix typo in domain name in account_threepid_delegates config option (#6273)
  Remove redundant arguments to CI's flake8 (#6277)
  Handle FileNotFound error in checking git repository version (#6284)
  Don't return coroutines
  Newsfile
  Port receipt and read markers to async/wait
  Make concurrently_execute work with async/await
  Newsfile
  Port federation_server to async/await
  Newsfile
  Port room rest handlers to async/await
  Newsfile
  Port replication http server endpoints to async/await
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit 'b39ca49db':
  Handle FileNotFound error in checking git repository version (#6284)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants