@@ -373,7 +373,12 @@ where
373
373
if show_pii {
374
374
results_by_hours. sort_by ( |a, b| a. hours . partial_cmp ( & b. hours ) . unwrap_or ( std:: cmp:: Ordering :: Equal ) ) ;
375
375
for entry in results_by_hours. iter ( ) {
376
- entry. write_to ( total_hours, file_stats, line_stats, & mut out) ?;
376
+ entry. write_to (
377
+ total_hours,
378
+ file_stats. then ( || total_files) ,
379
+ line_stats. then ( || total_lines) ,
380
+ & mut out,
381
+ ) ?;
377
382
writeln ! ( out) ?;
378
383
}
379
384
}
@@ -543,8 +548,8 @@ impl WorkByPerson {
543
548
fn write_to (
544
549
& self ,
545
550
total_hours : f32 ,
546
- show_files : bool ,
547
- show_lines : bool ,
551
+ total_files : Option < FileStats > ,
552
+ total_lines : Option < LineStats > ,
548
553
mut out : impl std:: io:: Write ,
549
554
) -> std:: io:: Result < ( ) > {
550
555
writeln ! (
@@ -561,18 +566,23 @@ impl WorkByPerson {
561
566
self . hours / HOURS_PER_WORKDAY ,
562
567
( self . hours / total_hours) * 100.0
563
568
) ?;
564
- if show_files {
569
+ if let Some ( total ) = total_files {
565
570
writeln ! (
566
571
out,
567
- "total files added/removed/modified: {}/{}/{}" ,
568
- self . files. added, self . files. removed, self . files. modified
572
+ "total files added/removed/modified: {}/{}/{} ({:.02}%)" ,
573
+ self . files. added,
574
+ self . files. removed,
575
+ self . files. modified,
576
+ ( self . files. sum( ) / total. sum( ) ) * 100.0
569
577
) ?;
570
578
}
571
- if show_lines {
579
+ if let Some ( total ) = total_lines {
572
580
writeln ! (
573
581
out,
574
- "total lines added/removed: {}/{}" ,
575
- self . lines. added, self . lines. removed
582
+ "total lines added/removed: {}/{} ({:.02}%)" ,
583
+ self . lines. added,
584
+ self . lines. removed,
585
+ ( self . lines. sum( ) / total. sum( ) ) * 100.0
576
586
) ?;
577
587
}
578
588
Ok ( ( ) )
@@ -622,6 +632,10 @@ impl FileStats {
622
632
a. add ( other) ;
623
633
a
624
634
}
635
+
636
+ fn sum ( & self ) -> f32 {
637
+ ( self . added + self . removed + self . modified ) as f32
638
+ }
625
639
}
626
640
627
641
impl LineStats {
@@ -636,4 +650,8 @@ impl LineStats {
636
650
a. add ( other) ;
637
651
a
638
652
}
653
+
654
+ fn sum ( & self ) -> f32 {
655
+ ( self . added + self . removed ) as f32
656
+ }
639
657
}
0 commit comments