@@ -32,7 +32,7 @@ struct Info {
32
32
version : String ,
33
33
dominant_language : Language ,
34
34
languages : Vec < ( Language , f64 ) > ,
35
- authors : Vec < String > ,
35
+ authors : Vec < ( String , usize , usize ) > ,
36
36
last_change : String ,
37
37
repo : String ,
38
38
commits : String ,
@@ -102,12 +102,12 @@ impl fmt::Display for Info {
102
102
"Author: "
103
103
} ;
104
104
105
- writeln ! ( buffer, "{}{} " , title. color( color) . bold( ) , self . authors[ 0 ] ) ?;
105
+ writeln ! ( buffer, "{}{:3}% {:15} {} " , title. color( color) . bold( ) , self . authors[ 0 ] . 2 , self . authors [ 0 ] . 0 , self . authors [ 0 ] . 1 ) ?;
106
106
107
107
let title = " " . repeat ( title. len ( ) ) ;
108
108
109
109
for author in self . authors . iter ( ) . skip ( 1 ) {
110
- writeln ! ( buffer, "{}{} " , title. color( color) . bold( ) , author) ?;
110
+ writeln ! ( buffer, "{}{:3}% {:15} {} " , title. color( color) . bold( ) , author. 2 , author . 0 , author . 1 ) ?;
111
111
}
112
112
}
113
113
@@ -568,7 +568,7 @@ fn get_configuration(dir: &str) -> Result<Configuration> {
568
568
}
569
569
570
570
// Return first n most active commiters as authors within this project.
571
- fn get_authors ( dir : & str , n : usize ) -> Vec < String > {
571
+ fn get_authors ( dir : & str , n : usize ) -> Vec < ( String , usize , usize ) > {
572
572
let output = Command :: new ( "git" )
573
573
. arg ( "-C" )
574
574
. arg ( dir)
@@ -579,10 +579,12 @@ fn get_authors(dir: &str, n: usize) -> Vec<String> {
579
579
580
580
// create map for storing author name as a key and their commit count as value
581
581
let mut authors = HashMap :: new ( ) ;
582
+ let mut total_commits = 0 ;
582
583
let output = String :: from_utf8_lossy ( & output. stdout ) ;
583
584
for line in output. lines ( ) {
584
585
let commit_count = authors. entry ( line. to_string ( ) ) . or_insert ( 0 ) ;
585
586
* commit_count += 1 ;
587
+ total_commits += 1 ;
586
588
}
587
589
588
590
// sort authors by commit count where the one with most commit count is first
@@ -595,9 +597,9 @@ fn get_authors(dir: &str, n: usize) -> Vec<String> {
595
597
596
598
// get only authors without their commit count
597
599
// and string "'" prefix and suffix
598
- let authors: Vec < String > = authors
600
+ let authors: Vec < ( String , usize , usize ) > = authors
599
601
. into_iter ( )
600
- . map ( |( author, _ ) | author. trim_matches ( '\'' ) . to_string ( ) )
602
+ . map ( |( author, count ) | ( author. trim_matches ( '\'' ) . to_string ( ) , count , count * 100 /total_commits ) )
601
603
. collect ( ) ;
602
604
603
605
authors
0 commit comments