@@ -653,7 +653,7 @@ def test_meta_hook_passes(
653653 (
654654 'hooks' , (
655655 OrderedDict ((
656- ('id' , 'test-hook ' ),
656+ ('id' , 'check-useless-excludes ' ),
657657 )),
658658 ),
659659 ),
@@ -663,13 +663,78 @@ def test_meta_hook_passes(
663663 _test_run (
664664 cap_out ,
665665 repo_with_passing_hook ,
666- opts = {'verbose' : True },
667- expected_outputs = [b'Hello World! ' ],
666+ opts = {},
667+ expected_outputs = [b'Check for useless excludes ' ],
668668 expected_ret = 0 ,
669669 stage = False ,
670670 )
671671
672672
673+ def test_useless_exclude_global (
674+ cap_out , repo_with_passing_hook , mock_out_store_directory ,
675+ ):
676+ config = OrderedDict ((
677+ ('exclude' , 'foo' ),
678+ (
679+ 'repos' , [
680+ OrderedDict ((
681+ ('repo' , 'meta' ),
682+ (
683+ 'hooks' , (
684+ OrderedDict ((
685+ ('id' , 'check-useless-excludes' ),
686+ )),
687+ ),
688+ ),
689+ )),
690+ ],
691+ ),
692+ ))
693+ add_config_to_repo (repo_with_passing_hook , config )
694+
695+ _test_run (
696+ cap_out ,
697+ repo_with_passing_hook ,
698+ opts = {'all_files' : True },
699+ expected_outputs = [
700+ b'Check for useless excludes' ,
701+ b'The global exclude pattern does not match any files' ,
702+ ],
703+ expected_ret = 1 ,
704+ stage = False ,
705+ )
706+
707+
708+ def test_useless_exclude_for_hook (
709+ cap_out , repo_with_passing_hook , mock_out_store_directory ,
710+ ):
711+ config = OrderedDict ((
712+ ('repo' , 'meta' ),
713+ (
714+ 'hooks' , (
715+ OrderedDict ((
716+ ('id' , 'check-useless-excludes' ),
717+ ('exclude' , 'foo' ),
718+ )),
719+ ),
720+ ),
721+ ))
722+ add_config_to_repo (repo_with_passing_hook , config )
723+
724+ _test_run (
725+ cap_out ,
726+ repo_with_passing_hook ,
727+ opts = {'all_files' : True },
728+ expected_outputs = [
729+ b'Check for useless excludes' ,
730+ b'The exclude pattern for check-useless-excludes '
731+ b'does not match any files' ,
732+ ],
733+ expected_ret = 1 ,
734+ stage = False ,
735+ )
736+
737+
673738@pytest .yield_fixture
674739def modified_config_repo (repo_with_passing_hook ):
675740 with modify_config (repo_with_passing_hook , commit = False ) as config :
0 commit comments