@@ -57,8 +57,8 @@ pub struct HookRunResponse {
5757 pub stdout : String ,
5858 /// stderr output emitted by hook
5959 pub stderr : String ,
60- /// exit code as reported back from process calling the hook (None if successful )
61- pub code : Option < i32 > ,
60+ /// exit code as reported back from process calling the hook (0 = success )
61+ pub code : i32 ,
6262}
6363
6464#[ derive( Debug , PartialEq , Eq ) ]
@@ -73,15 +73,15 @@ impl HookResult {
7373 /// helper to check if result is ok (hook succeeded with exit code 0)
7474 pub const fn is_ok ( & self ) -> bool {
7575 match self {
76- Self :: Run ( response) => response. code . is_none ( ) ,
77- Self :: NoHookFound => false ,
76+ Self :: Run ( response) => response. code == 0 ,
77+ Self :: NoHookFound => true ,
7878 }
7979 }
8080
8181 /// helper to check if result was run and not successful (non-zero exit code)
8282 pub const fn is_not_successful ( & self ) -> bool {
8383 match self {
84- Self :: Run ( response) => response. code . is_some ( ) ,
84+ Self :: Run ( response) => response. code != 0 ,
8585 Self :: NoHookFound => false ,
8686 }
8787 }
@@ -90,7 +90,7 @@ impl HookResult {
9090impl HookRunResponse {
9191 /// Check if the hook succeeded (exit code 0)
9292 pub const fn is_successful ( & self ) -> bool {
93- self . code . is_none ( )
93+ self . code == 0
9494 }
9595}
9696
@@ -424,7 +424,7 @@ exit 0
424424
425425 let stdout = response. stdout . as_str ( ) . trim_ascii_end ( ) ;
426426
427- assert_eq ! ( response. code, Some ( 42 ) ) ;
427+ assert_eq ! ( response. code, 42 ) ;
428428 assert_eq ! ( response. hook, hook. hook) ;
429429 assert_eq ! ( stdout, TEXT , "{:?} != {TEXT:?}" , stdout) ;
430430 assert ! ( response. stderr. is_empty( ) ) ;
@@ -561,7 +561,7 @@ exit 1
561561 unreachable ! ( )
562562 } ;
563563
564- assert_eq ! ( response. code. unwrap ( ) , 1 ) ;
564+ assert_eq ! ( response. code, 1 ) ;
565565 assert_eq ! ( & response. stdout, "rejected\n " ) ;
566566 }
567567
@@ -640,7 +640,7 @@ sys.exit(1)
640640 unreachable ! ( )
641641 } ;
642642
643- assert_eq ! ( response. code. unwrap ( ) , 1 ) ;
643+ assert_eq ! ( response. code, 1 ) ;
644644 assert_eq ! ( & response. stdout, "rejected\n " ) ;
645645
646646 assert_eq ! ( msg, String :: from( "msg\n " ) ) ;
@@ -735,7 +735,7 @@ exit 2
735735 unreachable ! ( )
736736 } ;
737737
738- assert_eq ! ( response. code. unwrap ( ) , 2 ) ;
738+ assert_eq ! ( response. code, 2 ) ;
739739 assert_eq ! ( & response. stdout, "rejected\n " ) ;
740740
741741 assert_eq ! (
@@ -790,7 +790,7 @@ exit 3
790790 let HookResult :: Run ( response) = res else {
791791 unreachable ! ( )
792792 } ;
793- assert_eq ! ( response. code. unwrap ( ) , 3 ) ;
793+ assert_eq ! ( response. code, 3 ) ;
794794 assert_eq ! ( & response. stdout, "failed\n " ) ;
795795 }
796796
0 commit comments