@@ -2,9 +2,7 @@ use crate::info::author::Author;
22use crate :: info:: head_refs:: HeadRefs ;
33use anyhow:: { Context , Result } ;
44use byte_unit:: Byte ;
5- use git2:: {
6- BranchType , Repository , RepositoryOpenFlags , Signature , Status , StatusOptions , StatusShow ,
7- } ;
5+ use git2:: { BranchType , Repository , RepositoryOpenFlags , Status , StatusOptions , StatusShow } ;
86use git_repository as git;
97use git_repository:: bstr:: ByteSlice ;
108use regex:: Regex ;
@@ -26,23 +24,12 @@ pub struct Repo<'a> {
2624
2725#[ derive( Hash , PartialEq , Eq ) ]
2826pub struct Sig {
29- name : String ,
30- email : String ,
31- }
32-
33- // TODO: make Sig use BString, to avoid allocations/utf8 checks
34- impl From < Signature < ' _ > > for Sig {
35- fn from ( sig : Signature ) -> Self {
36- let name = String :: from_utf8_lossy ( sig. name_bytes ( ) ) . into_owned ( ) ;
37- let email = String :: from_utf8_lossy ( sig. email_bytes ( ) ) . into_owned ( ) ;
38- Self { name, email }
39- }
27+ name : git:: bstr:: BString ,
28+ email : git:: bstr:: BString ,
4029}
4130
4231impl From < git:: actor:: Signature > for Sig {
43- fn from ( sig : git:: actor:: Signature ) -> Self {
44- let name = sig. name . to_string ( ) ;
45- let email = sig. email . to_string ( ) ;
32+ fn from ( git:: actor:: Signature { name, email, .. } : git:: actor:: Signature ) -> Self {
4633 Self { name, email }
4734 }
4835}
@@ -159,9 +146,10 @@ impl<'a> Repo<'a> {
159146 let authors: Vec < Author > = authors_by_number_of_commits
160147 . into_iter ( )
161148 . map ( |( author, author_nbr_of_commits) | {
149+ let email = author. email ;
162150 Author :: new (
163- author. name . clone ( ) ,
164- show_email. then ( || author . email ) ,
151+ author. name ,
152+ show_email. then ( || email) ,
165153 author_nbr_of_commits,
166154 total_nbr_of_commits,
167155 )
0 commit comments