Merge pull request #1721 from pre-commit/dont_crash_on_cygwin_check

don't crash on cygwin mismatch check
This commit is contained in:
Anthony Sottile 2020-11-28 15:48:30 -08:00 committed by GitHub
commit 92ce2dcbc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,7 +201,10 @@ def check_for_cygwin_mismatch() -> None:
"""See https://github.com/pre-commit/pre-commit/issues/354""" """See https://github.com/pre-commit/pre-commit/issues/354"""
if sys.platform in ('cygwin', 'win32'): # pragma: no cover (windows) if sys.platform in ('cygwin', 'win32'): # pragma: no cover (windows)
is_cygwin_python = sys.platform == 'cygwin' is_cygwin_python = sys.platform == 'cygwin'
toplevel = get_root() try:
toplevel = get_root()
except FatalError: # skip the check if we're not in a git repo
return
is_cygwin_git = toplevel.startswith('/') is_cygwin_git = toplevel.startswith('/')
if is_cygwin_python ^ is_cygwin_git: if is_cygwin_python ^ is_cygwin_git: