@@ -6,7 +6,6 @@ use git2::{Repository, RepositoryOpenFlags, Status, StatusOptions, StatusShow};
6
6
use git_repository as git;
7
7
use git_repository:: bstr:: ByteSlice ;
8
8
use regex:: Regex ;
9
- use std:: cmp:: Ordering ;
10
9
use std:: collections:: HashMap ;
11
10
use std:: path:: Path ;
12
11
use time:: format_description:: well_known:: Rfc3339 ;
@@ -26,63 +25,15 @@ pub struct Repo<'a> {
26
25
time_of_first_commit : git:: actor:: Time ,
27
26
}
28
27
28
+ #[ derive( Hash , PartialOrd , Ord , Eq , PartialEq ) ]
29
29
pub struct Sig {
30
30
name : git:: bstr:: BString ,
31
31
email : git:: bstr:: BString ,
32
- email_lowercase : Option < String > ,
33
32
}
34
33
35
34
impl From < git:: actor:: Signature > for Sig {
36
35
fn from ( git:: actor:: Signature { name, email, .. } : git:: actor:: Signature ) -> Self {
37
- let needs_lowercase = email. chars ( ) . any ( |c| c. to_ascii_lowercase ( ) != c) ;
38
- let email_lowercase = needs_lowercase. then ( || email. chars ( ) . collect :: < String > ( ) ) ;
39
- Self {
40
- name,
41
- email,
42
- email_lowercase,
43
- }
44
- }
45
- }
46
-
47
- impl std:: hash:: Hash for Sig {
48
- fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
49
- self . email_lowercase
50
- . as_ref ( )
51
- . map ( |email_lc| email_lc. hash ( state) )
52
- . unwrap_or_else ( || self . email . hash ( state) ) ;
53
- self . name . hash ( state) ;
54
- }
55
- }
56
-
57
- impl Eq for Sig { }
58
-
59
- impl PartialEq < Self > for Sig {
60
- fn eq ( & self , other : & Self ) -> bool {
61
- self . cmp ( other) == Ordering :: Equal
62
- }
63
- }
64
-
65
- impl PartialOrd < Self > for Sig {
66
- fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
67
- self . cmp ( other) . into ( )
68
- }
69
- }
70
-
71
- impl Ord for Sig {
72
- fn cmp ( & self , other : & Self ) -> Ordering {
73
- self . email_lowercase
74
- . as_ref ( )
75
- . and_then ( |a_email_lc| {
76
- other
77
- . email_lowercase
78
- . as_ref ( )
79
- . map ( |b_email_lc| ( a_email_lc, b_email_lc) )
80
- } )
81
- . map_or_else (
82
- || self . email . cmp ( & other. email ) ,
83
- |( a_email_lc, b_email_lc) | a_email_lc. cmp ( b_email_lc) ,
84
- )
85
- . then_with ( || self . name . cmp ( & other. name ) )
36
+ Self { name, email }
86
37
}
87
38
}
88
39
0 commit comments