@@ -20,6 +20,8 @@ pub struct Repo<'a> {
20
20
authors : Vec < Author > ,
21
21
total_num_authors : usize ,
22
22
num_commits : usize ,
23
+ /// false if we have found the first commit that started it all, true if the repository is shallow.
24
+ is_shallow : bool ,
23
25
time_of_most_recent_commit : git:: actor:: Time ,
24
26
time_of_first_commit : git:: actor:: Time ,
25
27
}
@@ -100,6 +102,7 @@ impl<'a> Repo<'a> {
100
102
let mut time_of_most_recent_commit = None ;
101
103
let mut time_of_first_commit = None ;
102
104
let mut commit_iter = repo. head_commit ( ) ?. ancestors ( ) . all ( ) . peekable ( ) ;
105
+ let mut is_shallow = false ;
103
106
104
107
let mailmap = repo. load_mailmap ( ) ;
105
108
let mut author_to_number_of_commits: HashMap < Sig , usize > = HashMap :: new ( ) ;
@@ -112,7 +115,10 @@ impl<'a> Repo<'a> {
112
115
. object ( )
113
116
. expect ( "commit is still present/comes from cache" )
114
117
. into_commit ( ) ,
115
- Err ( git:: traverse:: commit:: ancestors:: Error :: FindExisting { .. } ) => break , // assume a shallow clone
118
+ Err ( git:: traverse:: commit:: ancestors:: Error :: FindExisting { .. } ) => {
119
+ is_shallow = true ;
120
+ break ;
121
+ }
116
122
Err ( err) => return Err ( err. into ( ) ) ,
117
123
} ;
118
124
@@ -174,6 +180,7 @@ impl<'a> Repo<'a> {
174
180
authors,
175
181
total_num_authors,
176
182
num_commits,
183
+ is_shallow,
177
184
time_of_first_commit,
178
185
time_of_most_recent_commit,
179
186
} )
@@ -184,7 +191,11 @@ impl<'a> Repo<'a> {
184
191
}
185
192
186
193
pub fn get_number_of_commits ( & self ) -> String {
187
- self . num_commits . to_string ( )
194
+ format ! (
195
+ "{}{}" ,
196
+ self . num_commits,
197
+ self . is_shallow. then( || " (shallow)" ) . unwrap_or_default( )
198
+ )
188
199
}
189
200
190
201
pub fn take_authors ( & mut self , show_email : bool ) -> ( Vec < Author > , usize ) {
0 commit comments