@@ -364,75 +364,73 @@ impl CommitComponent {
364
364
365
365
let repo_state = sync:: repo_state ( & self . repo . borrow ( ) ) ?;
366
366
367
- self . mode =
368
- if repo_state != RepoState :: Clean && reword. is_some ( ) {
369
- bail ! ( "cannot reword while repo is not in a clean state" ) ;
370
- } else if let Some ( reword_id) = reword {
371
- self . input . set_text (
372
- sync:: get_commit_details (
367
+ self . mode = if repo_state != RepoState :: Clean
368
+ && reword. is_some ( )
369
+ {
370
+ bail ! ( "cannot reword while repo is not in a clean state" ) ;
371
+ } else if let Some ( reword_id) = reword {
372
+ self . input . set_text (
373
+ sync:: get_commit_details (
374
+ & self . repo . borrow ( ) ,
375
+ reword_id,
376
+ ) ?
377
+ . message
378
+ . unwrap_or_default ( )
379
+ . combine ( ) ,
380
+ ) ;
381
+ self . input . set_title ( strings:: commit_reword_title ( ) ) ;
382
+ Mode :: Reword ( reword_id)
383
+ } else {
384
+ match repo_state {
385
+ RepoState :: Merge => {
386
+ let ids =
387
+ sync:: mergehead_ids ( & self . repo . borrow ( ) ) ?;
388
+ self . input
389
+ . set_title ( strings:: commit_title_merge ( ) ) ;
390
+ self . input . set_text ( sync:: merge_msg (
373
391
& self . repo . borrow ( ) ,
374
- reword_id,
375
- ) ?
376
- . message
377
- . unwrap_or_default ( )
378
- . combine ( ) ,
379
- ) ;
380
- self . input . set_title ( strings:: commit_reword_title ( ) ) ;
381
- Mode :: Reword ( reword_id)
382
- } else {
383
- match repo_state {
384
- RepoState :: Merge => {
385
- let ids =
386
- sync:: mergehead_ids ( & self . repo . borrow ( ) ) ?;
387
- self . input
388
- . set_title ( strings:: commit_title_merge ( ) ) ;
389
- self . input . set_text ( sync:: merge_msg (
390
- & self . repo . borrow ( ) ,
391
- ) ?) ;
392
- Mode :: Merge ( ids)
393
- }
394
- RepoState :: Revert => {
395
- self . input
396
- . set_title ( strings:: commit_title_revert ( ) ) ;
397
- self . input . set_text ( sync:: merge_msg (
398
- & self . repo . borrow ( ) ,
399
- ) ?) ;
400
- Mode :: Revert
401
- }
392
+ ) ?) ;
393
+ Mode :: Merge ( ids)
394
+ }
395
+ RepoState :: Revert => {
396
+ self . input
397
+ . set_title ( strings:: commit_title_revert ( ) ) ;
398
+ self . input . set_text ( sync:: merge_msg (
399
+ & self . repo . borrow ( ) ,
400
+ ) ?) ;
401
+ Mode :: Revert
402
+ }
402
403
403
- _ => {
404
- self . commit_template = get_config_string (
405
- & self . repo . borrow ( ) ,
406
- "commit.template" ,
407
- )
408
- . map_err ( |e| {
409
- log:: error!(
410
- "load git-config failed: {}" ,
404
+ _ => {
405
+ self . commit_template = get_config_string (
406
+ & self . repo . borrow ( ) ,
407
+ "commit.template" ,
408
+ )
409
+ . map_err ( |e| {
410
+ log:: error!( "load git-config failed: {}" , e) ;
411
+ e
412
+ } )
413
+ . ok ( )
414
+ . flatten ( )
415
+ . and_then ( |path| {
416
+ read_to_string ( & path)
417
+ . map_err ( |e| {
418
+ log:: error!( "read commit.template failed: {e} (path: '{path}')" ) ;
411
419
e
412
- ) ;
413
- e
414
- } )
415
- . ok ( )
416
- . flatten ( )
417
- . and_then ( |path| {
418
- read_to_string ( path)
419
- . map_err ( |e| {
420
- log:: error!( "read commit.template failed: {}" , e) ;
421
- e
422
- } )
423
- . ok ( )
424
- } ) ;
425
-
426
- if self . is_empty ( ) {
427
- if let Some ( s) = & self . commit_template {
428
- self . input . set_text ( s. clone ( ) ) ;
429
- }
420
+ } )
421
+ . ok ( )
422
+ } ) ;
423
+
424
+ if self . is_empty ( ) {
425
+ if let Some ( s) = & self . commit_template {
426
+ self . input . set_text ( s. clone ( ) ) ;
430
427
}
431
- self . input . set_title ( strings:: commit_title ( ) ) ;
432
- Mode :: Normal
433
428
}
429
+ self . input . set_title ( strings:: commit_title ( ) ) ;
430
+ Mode :: Normal
434
431
}
435
- } ;
432
+ }
433
+ } ;
436
434
437
435
self . commit_msg_history_idx = 0 ;
438
436
self . input . show ( ) ?;
0 commit comments