File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 (
Original file line number Diff line number Diff line change 77import pytest
88
99from pre_commit import main
10+ from pre_commit .error_handler import PreCommitSystemExit
1011from pre_commit .util import cwd
1112from 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+ )
You can’t perform that action at this time.
0 commit comments