@@ -238,16 +238,28 @@ impl CommitPopup {
238
238
239
239
if verify {
240
240
// run pre commit hook - can reject commit
241
- if let HookResult :: NotOk ( e) =
242
- sync:: hooks_pre_commit_with_timeout (
243
- & self . repo . borrow ( ) ,
244
- self . get_hook_timeout ( ) ,
245
- ) ? {
246
- log:: error!( "pre-commit hook error: {}" , e) ;
247
- self . queue . push ( InternalEvent :: ShowErrorMsg (
248
- format ! ( "pre-commit hook error:\n {e}" ) ,
249
- ) ) ;
250
- return Ok ( CommitResult :: Aborted ) ;
241
+ match sync:: hooks_pre_commit_with_timeout (
242
+ & self . repo . borrow ( ) ,
243
+ self . get_hook_timeout ( ) ,
244
+ ) ? {
245
+ HookResult :: NotOk ( e) => {
246
+ log:: error!( "pre-commit hook error: {}" , e) ;
247
+ self . queue . push ( InternalEvent :: ShowErrorMsg (
248
+ format ! ( "pre-commit hook error:\n {e}" ) ,
249
+ ) ) ;
250
+ return Ok ( CommitResult :: Aborted ) ;
251
+ }
252
+ HookResult :: TimedOut => {
253
+ log:: error!( "pre-commit hook timed out" ) ;
254
+ self . queue . push ( InternalEvent :: ShowErrorMsg (
255
+ format ! (
256
+ "pre-commit hook timed out after {} seconds" ,
257
+ self . get_hook_timeout( ) . as_secs( )
258
+ ) ,
259
+ ) ) ;
260
+ return Ok ( CommitResult :: Aborted ) ;
261
+ }
262
+ HookResult :: Ok => { }
251
263
}
252
264
}
253
265
@@ -256,30 +268,53 @@ impl CommitPopup {
256
268
257
269
if verify {
258
270
// run commit message check hook - can reject commit
259
- if let HookResult :: NotOk ( e) =
260
- sync:: hooks_commit_msg_with_timeout (
261
- & self . repo . borrow ( ) ,
262
- & mut msg,
263
- self . get_hook_timeout ( ) ,
264
- ) ? {
265
- log:: error!( "commit-msg hook error: {}" , e) ;
266
- self . queue . push ( InternalEvent :: ShowErrorMsg (
267
- format ! ( "commit-msg hook error:\n {e}" ) ,
268
- ) ) ;
269
- return Ok ( CommitResult :: Aborted ) ;
271
+ match sync:: hooks_commit_msg_with_timeout (
272
+ & self . repo . borrow ( ) ,
273
+ & mut msg,
274
+ self . get_hook_timeout ( ) ,
275
+ ) ? {
276
+ HookResult :: NotOk ( e) => {
277
+ log:: error!( "commit-msg hook error: {}" , e) ;
278
+ self . queue . push ( InternalEvent :: ShowErrorMsg (
279
+ format ! ( "commit-msg hook error:\n {e}" ) ,
280
+ ) ) ;
281
+ return Ok ( CommitResult :: Aborted ) ;
282
+ }
283
+ HookResult :: TimedOut => {
284
+ log:: error!( "commit-msg hook timed out" ) ;
285
+ self . queue . push ( InternalEvent :: ShowErrorMsg (
286
+ format ! (
287
+ "commit-msg hook timed out after {} seconds" ,
288
+ self . get_hook_timeout( ) . as_secs( )
289
+ ) ,
290
+ ) ) ;
291
+ return Ok ( CommitResult :: Aborted ) ;
292
+ }
293
+ HookResult :: Ok => { }
270
294
}
271
295
}
272
296
self . do_commit ( & msg) ?;
273
297
274
- if let HookResult :: NotOk ( e) =
275
- sync:: hooks_post_commit_with_timeout (
276
- & self . repo . borrow ( ) ,
277
- self . get_hook_timeout ( ) ,
278
- ) ? {
279
- log:: error!( "post-commit hook error: {}" , e) ;
280
- self . queue . push ( InternalEvent :: ShowErrorMsg ( format ! (
281
- "post-commit hook error:\n {e}"
282
- ) ) ) ;
298
+ match sync:: hooks_post_commit_with_timeout (
299
+ & self . repo . borrow ( ) ,
300
+ self . get_hook_timeout ( ) ,
301
+ ) ? {
302
+ HookResult :: NotOk ( e) => {
303
+ log:: error!( "post-commit hook error: {}" , e) ;
304
+ self . queue . push ( InternalEvent :: ShowErrorMsg (
305
+ format ! ( "post-commit hook error:\n {e}" ) ,
306
+ ) ) ;
307
+ }
308
+ HookResult :: TimedOut => {
309
+ log:: error!( "post-commit hook timed out" ) ;
310
+ self . queue . push ( InternalEvent :: ShowErrorMsg (
311
+ format ! (
312
+ "post-commit hook timed out after {} seconds" ,
313
+ self . get_hook_timeout( ) . as_secs( )
314
+ ) ,
315
+ ) ) ;
316
+ }
317
+ HookResult :: Ok => { }
283
318
}
284
319
285
320
Ok ( CommitResult :: CommitDone )
@@ -488,10 +523,11 @@ impl CommitPopup {
488
523
Ok ( msg)
489
524
}
490
525
491
- // TODO - Configurable timeout
492
- #[ allow( clippy:: unused_self, clippy:: missing_const_for_fn) ]
493
526
fn get_hook_timeout ( & self ) -> Duration {
494
- Duration :: from_secs ( 5 )
527
+ self . options
528
+ . borrow ( )
529
+ . hook_timeout ( )
530
+ . unwrap_or ( Duration :: ZERO )
495
531
}
496
532
}
497
533
0 commit comments