From 8cfe8e590d9568ff8fb9d5deb0c46776ee966162 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 28 Nov 2020 15:16:52 -0800 Subject: [PATCH] don't crash on cygwin mismatch check --- pre_commit/git.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pre_commit/git.py b/pre_commit/git.py index 8e22dcf0..156e53d2 100644 --- a/pre_commit/git.py +++ b/pre_commit/git.py @@ -201,7 +201,10 @@ def check_for_cygwin_mismatch() -> None: """See https://github.com/pre-commit/pre-commit/issues/354""" if sys.platform in ('cygwin', 'win32'): # pragma: no cover (windows) 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('/') if is_cygwin_python ^ is_cygwin_git: