@@ -2,6 +2,7 @@ use crate::cli::{self, Config};
22use crate :: error:: * ;
33use crate :: ui:: get_ascii_colors;
44use crate :: ui:: text_color:: TextColor ;
5+ use author:: Author ;
56use colored:: { Color , ColoredString , Colorize } ;
67use deps:: DependencyDetector ;
78use git2:: Repository ;
@@ -12,6 +13,7 @@ use repo::Repo;
1213use serde:: ser:: SerializeStruct ;
1314use serde:: Serialize ;
1415
16+ mod author;
1517pub mod deps;
1618mod head_refs;
1719pub mod info_field;
@@ -31,8 +33,9 @@ pub struct Info {
3133 creation_date : String ,
3234 languages : Vec < ( Language , f64 ) > ,
3335 dependencies : String ,
34- authors : Vec < ( String , Option < String > , usize , usize ) > ,
36+ authors : Vec < Author > ,
3537 last_change : String ,
38+ contributors : usize ,
3639 repo_url : String ,
3740 number_of_commits : String ,
3841 lines_of_code : usize ,
@@ -151,6 +154,17 @@ impl std::fmt::Display for Info {
151154 ) ?;
152155 }
153156
157+ if !self . config . disabled_fields . contributors
158+ && self . contributors > self . config . number_of_authors
159+ {
160+ writeln ! (
161+ f,
162+ "{}{}" ,
163+ & self . get_formatted_subtitle_label( "Contributors" ) ,
164+ & self . contributors. to_string( ) . color( self . text_colors. info) ,
165+ ) ?;
166+ }
167+
154168 if !self . config . disabled_fields . repo && !self . repo_url . is_empty ( ) {
155169 writeln ! (
156170 f,
@@ -231,7 +245,8 @@ impl Info {
231245 let number_of_branches = internal_repo. get_number_of_branches ( ) ?;
232246 let creation_date = internal_repo. get_creation_date ( config. iso_time ) ?;
233247 let number_of_commits = internal_repo. get_number_of_commits ( ) ;
234- let authors = internal_repo. get_authors ( config. number_of_authors , config. show_email ) ?;
248+ let ( authors, contributors) =
249+ internal_repo. get_authors ( config. number_of_authors , config. show_email ) ?;
235250 let last_change = internal_repo. get_date_of_last_commit ( config. iso_time ) ;
236251 let ( repo_size, file_count) = internal_repo. get_repo_size ( ) ;
237252 let workdir = internal_repo. get_work_dir ( ) ?;
@@ -262,6 +277,7 @@ impl Info {
262277 dependencies,
263278 authors,
264279 last_change,
280+ contributors,
265281 repo_url,
266282 number_of_commits,
267283 lines_of_code,
@@ -322,33 +338,11 @@ impl Info {
322338
323339 let pad = title. len ( ) + 2 ;
324340
325- for ( i, ( author_name, author_email_opt, author_nbr_commits, autor_contribution) ) in
326- self . authors . iter ( ) . enumerate ( )
327- {
328- let author = if let Some ( author_email) = author_email_opt {
329- format ! ( "{} <{}>" , author_name, author_email)
330- } else {
331- author_name. to_owned ( )
332- } ;
333-
341+ for ( i, author) in self . authors . iter ( ) . enumerate ( ) {
334342 if i == 0 {
335- author_field. push_str ( & format ! (
336- "{}{} {} {}\n " ,
337- autor_contribution. to_string( ) . color( self . text_colors. info) ,
338- "%" . color( self . text_colors. info) ,
339- author. to_string( ) . color( self . text_colors. info) ,
340- author_nbr_commits. to_string( ) . color( self . text_colors. info) ,
341- ) ) ;
343+ author_field. push_str ( & format ! ( "{}\n " , author) ) ;
342344 } else {
343- author_field. push_str ( & format ! (
344- "{:<width$}{}{} {} {}\n " ,
345- "" ,
346- autor_contribution. to_string( ) . color( self . text_colors. info) ,
347- "%" . color( self . text_colors. info) ,
348- author. to_string( ) . color( self . text_colors. info) ,
349- author_nbr_commits. to_string( ) . color( self . text_colors. info) ,
350- width = pad
351- ) ) ;
345+ author_field. push_str ( & format ! ( "{:<width$}{}\n " , "" , author, width = pad) ) ;
352346 }
353347 }
354348
@@ -433,15 +427,14 @@ impl Serialize for Info {
433427 {
434428 let mut state = serializer. serialize_struct ( "Info" , 15 ) ?;
435429 let langs: Vec < String > = self . languages . iter ( ) . map ( |( l, _) | format ! ( "{}" , l) ) . collect ( ) ;
436- let auths: Vec < String > = self . authors . iter ( ) . map ( |( l, _, _, _) | format ! ( "{}" , l) ) . collect ( ) ;
437430 state. serialize_field ( "repoName" , & self . repo_name ) ?;
438431 state. serialize_field ( "numberOfTags" , & self . number_of_tags ) ?;
439432 state. serialize_field ( "numberOfBranches" , & self . number_of_branches ) ?;
440433 state. serialize_field ( "headRefs" , & self . head_refs ) ?;
441434 state. serialize_field ( "version" , & self . version ) ?;
442435 state. serialize_field ( "creationDate" , & self . creation_date ) ?;
443436 state. serialize_field ( "languages" , & langs) ?;
444- state. serialize_field ( "authors" , & auths ) ?;
437+ state. serialize_field ( "authors" , & self . authors ) ?;
445438 state. serialize_field ( "lastChange" , & self . last_change ) ?;
446439 state. serialize_field ( "repoUrl" , & self . repo_url ) ?;
447440 state. serialize_field ( "numberOfCommits" , & self . number_of_commits ) ?;
0 commit comments