2020from pre_commit .runner import Runner
2121from pre_commit .util import cmd_output
2222from pre_commit .util import cwd
23+ from pre_commit .util import make_executable
2324from testing .auto_namedtuple import auto_namedtuple
2425from testing .fixtures import add_config_to_repo
2526from testing .fixtures import make_consuming_repo
@@ -43,7 +44,7 @@ def repo_with_failing_hook(tempdir_factory):
4344
4445
4546def stage_a_file (filename = 'foo.py' ):
46- cmd_output ( 'touch' , filename )
47+ open ( filename , 'a' ). close ( )
4748 cmd_output ('git' , 'add' , filename )
4849
4950
@@ -166,6 +167,22 @@ def test_types_hook_repository(
166167 assert b'bar.notpy' not in printed
167168
168169
170+ def test_exclude_types_hook_repository (
171+ cap_out , tempdir_factory , mock_out_store_directory ,
172+ ):
173+ git_path = make_consuming_repo (tempdir_factory , 'exclude_types_repo' )
174+ with cwd (git_path ):
175+ with io .open ('exe' , 'w' ) as exe :
176+ exe .write ('#!/usr/bin/env python3\n ' )
177+ make_executable ('exe' )
178+ cmd_output ('git' , 'add' , 'exe' )
179+ stage_a_file ('bar.py' )
180+ ret , printed = _do_run (cap_out , git_path , _get_opts ())
181+ assert ret == 1
182+ assert b'bar.py' in printed
183+ assert b'exe' not in printed
184+
185+
169186def test_show_diff_on_failure (
170187 capfd , cap_out , tempdir_factory , mock_out_store_directory ,
171188):
0 commit comments