@@ -8,24 +8,44 @@ pub(crate) fn check_just_installed() -> bool {
88 cmd ! ( "just" , "--version" ) . run ( ) . is_ok ( )
99}
1010
11- pub ( crate ) fn run_hook ( config : & AppConfig , script : String , hook_name : & str ) -> anyhow:: Result < ( ) > {
11+ pub ( crate ) fn run_hook (
12+ config : & AppConfig ,
13+ script : String ,
14+ hook_name : & str ,
15+ ) -> anyhow:: Result < bool > {
1216 if config. hooks . use_just && !check_just_installed ( ) {
1317 step ( "Install just to run hooks" ) ;
1418 // TODO: provide installation instructions
1519 }
20+
21+ // Run git hook
1622 if Path :: new ( & format ! ( ".git/hooks/{hook_name}" ) ) . exists ( )
1723 && !config
1824 . hooks
1925 . ignore_git_hooks
2026 . contains ( & hook_name. to_string ( ) )
2127 {
2228 step ( & format ! ( "Running {hook_name} hook" ) ) ;
23- cmd ! ( "git" , "hook" , "run" , hook_name) . run ( ) ?;
29+ if let Err ( e) = cmd ! ( "git" , "hook" , "run" , hook_name) . run ( )
30+ && hook_name. starts_with ( "pre-" )
31+ {
32+ anyhow:: bail!(
33+ "Git {} hook failed: {}. Aborting." ,
34+ hook_name,
35+ e. to_string( )
36+ )
37+ }
2438 }
39+
40+ // Run hj hook
2541 let ( program, args) : ( & str , Vec < & str > ) = script
2642 . split_once ( ' ' )
2743 . map ( |( p, a) | ( p, a. trim ( ) . split ( ' ' ) . collect ( ) ) )
2844 . unwrap_or ( ( & script, Vec :: new ( ) ) ) ;
29- cmd ( program, & args) . run ( ) ?;
30- Ok ( ( ) )
45+ if let Err ( e) = cmd ( program, & args) . run ( )
46+ && hook_name. starts_with ( "pre-" )
47+ {
48+ anyhow:: bail!( "HJ {} hook failed: {}. Aborting." , hook_name, e. to_string( ) ) ;
49+ }
50+ Ok ( true )
3151}
0 commit comments