Skip to content

Commit 4e0f73b

Browse files
committed
Add cygwin check after initialization. Resolves pre-commit#437
1 parent 88f9f76 commit 4e0f73b

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

pre_commit/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def main(argv=None):
152152

153153
with error_handler():
154154
add_logging_handler(args.color)
155-
git.check_for_cygwin_mismatch()
156155
runner = Runner.create()
156+
git.check_for_cygwin_mismatch()
157157

158158
if args.command == 'install':
159159
return install(

tests/main_test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pytest
88

99
from pre_commit import main
10+
from pre_commit.error_handler import PreCommitSystemExit
1011
from pre_commit.util import cwd
1112
from testing.auto_namedtuple import auto_namedtuple
1213

@@ -142,3 +143,16 @@ def test_help_cmd_in_empty_directory(
142143
mock.call(['help', 'run']),
143144
mock.call(['run', '--help']),
144145
])
146+
147+
148+
def test_expected_fatal_error_no_git_repo(
149+
tempdir_factory, cap_out, mock_out_store_directory,
150+
):
151+
with cwd(tempdir_factory.get()):
152+
with pytest.raises(PreCommitSystemExit):
153+
main.main([])
154+
assert cap_out.get() == (
155+
'An error has occurred: FatalError: git failed. '
156+
'Is it installed, and are you in a Git repository directory?\n'
157+
'Check the log at ~/.pre-commit/pre-commit.log\n'
158+
)

0 commit comments

Comments
 (0)