@@ -128,9 +128,9 @@ impl HookResult {
128128 }
129129 }
130130
131- /// helper to check if no hook was found
132- pub const fn is_no_hook_found ( & self ) -> bool {
133- matches ! ( self , Self :: NoHookFound )
131+ /// helper to check if a hook was found and ran (regardless of success/failure)
132+ pub const fn did_run_hook ( & self ) -> bool {
133+ matches ! ( self , Self :: Run ( _ ) )
134134 }
135135}
136136
@@ -401,6 +401,7 @@ exit 0
401401
402402 let res = hooks_post_commit ( & repo, None ) . unwrap ( ) ;
403403
404+ assert ! ( res. did_run_hook( ) ) ;
404405 assert ! ( res. is_ok( ) ) ;
405406 }
406407
@@ -417,6 +418,7 @@ exit 0
417418 let mut msg = String :: from ( "test" ) ;
418419 let res = hooks_commit_msg ( & repo, None , & mut msg) . unwrap ( ) ;
419420
421+ assert ! ( res. did_run_hook( ) ) ;
420422 assert ! ( res. is_ok( ) ) ;
421423
422424 assert_eq ! ( msg, String :: from( "test" ) ) ;
@@ -437,6 +439,7 @@ exit 0
437439 let mut msg = String :: from ( "test_sth" ) ;
438440 let res = hooks_commit_msg ( & repo, None , & mut msg) . unwrap ( ) ;
439441
442+ assert ! ( res. did_run_hook( ) ) ;
440443 assert ! ( res. is_ok( ) ) ;
441444
442445 assert_eq ! ( msg, String :: from( "test_shell_command" ) ) ;
@@ -452,6 +455,7 @@ exit 0
452455
453456 create_hook ( & repo, HOOK_PRE_COMMIT , hook) ;
454457 let res = hooks_pre_commit ( & repo, None ) . unwrap ( ) ;
458+ assert ! ( res. did_run_hook( ) ) ;
455459 assert ! ( res. is_ok( ) ) ;
456460 }
457461
@@ -511,6 +515,7 @@ exit 0
511515 let res =
512516 hooks_pre_commit ( & repo, Some ( & [ "../.myhooks" ] ) ) . unwrap ( ) ;
513517
518+ assert ! ( res. did_run_hook( ) ) ;
514519 assert ! ( res. is_ok( ) ) ;
515520 }
516521
@@ -544,6 +549,7 @@ exit 1
544549 let res =
545550 hooks_pre_commit ( & repo, Some ( & [ "../.myhooks" ] ) ) . unwrap ( ) ;
546551
552+ assert ! ( res. did_run_hook( ) ) ;
547553 assert ! ( res. is_ok( ) ) ;
548554 }
549555
@@ -651,6 +657,7 @@ sys.exit(0)
651657
652658 create_hook ( & repo, HOOK_PRE_COMMIT , hook) ;
653659 let res = hooks_pre_commit ( & repo, None ) . unwrap ( ) ;
660+ assert ! ( res. did_run_hook( ) ) ;
654661 assert ! ( res. is_ok( ) , "{res:?}" ) ;
655662 }
656663
@@ -714,6 +721,7 @@ exit 0
714721 let mut msg = String :: from ( "test" ) ;
715722 let res = hooks_commit_msg ( & repo, None , & mut msg) . unwrap ( ) ;
716723
724+ assert ! ( res. did_run_hook( ) ) ;
717725 assert ! ( res. is_ok( ) ) ;
718726 assert_eq ! ( msg, String :: from( "msg\n " ) ) ;
719727 }
@@ -760,6 +768,7 @@ exit 0
760768 )
761769 . unwrap ( ) ;
762770
771+ assert ! ( res. did_run_hook( ) ) ;
763772 assert ! ( res. is_ok( ) ) ;
764773 assert_eq ! ( msg, String :: from( "msg:message\n " ) ) ;
765774 }
@@ -828,6 +837,7 @@ exit 0
828837 )
829838 . unwrap ( ) ;
830839
840+ assert ! ( res. did_run_hook( ) ) ;
831841 assert ! ( res. is_ok( ) ) ;
832842 }
833843
@@ -890,6 +900,7 @@ exit 0
890900 )
891901 . unwrap ( ) ;
892902
903+ assert ! ( res. did_run_hook( ) ) ;
893904 assert ! ( res. is_ok( ) , "Expected Ok result, got: {res:?}" ) ;
894905 }
895906
0 commit comments