@@ -216,13 +216,15 @@ impl Info {
216
216
let head_refs = repo. get_head_refs ( ) ?;
217
217
let pending = repo. get_pending_changes ( ) ;
218
218
let version = repo. get_version ( ) ?;
219
+ let git_username = repo. get_git_username ( ) ?;
220
+ let number_of_tags = repo. get_number_of_tags ( ) ?;
221
+ let number_of_branches = repo. get_number_of_branches ( ) ?;
219
222
let git_history = Info :: get_git_history ( & workdir, config. no_merges ) ;
220
223
let creation_date = Info :: get_creation_date ( & git_history) ;
221
224
let number_of_commits = Info :: get_number_of_commits ( & git_history) ;
222
225
let authors = Info :: get_authors ( & git_history, config. number_of_authors ) ;
223
226
let last_change = Info :: get_date_of_last_commit ( & git_history) ;
224
- let ( number_of_tags, number_of_branches) = Info :: get_number_of_tags_branches ( & workdir) ;
225
- let ( git_v, git_user) = Info :: get_git_version_and_username ( & workdir) ;
227
+ let git_version = Info :: get_git_version ( ) ?;
226
228
let repo_size = Info :: get_packed_size ( & workdir) ;
227
229
let project_license = Detector :: new ( ) ?. get_project_license ( & workdir) ;
228
230
let dependencies = deps:: DependencyDetector :: new ( ) . get_dependencies ( & workdir) ?;
@@ -238,8 +240,8 @@ impl Info {
238
240
let text_colors = TextColor :: get_text_colors ( & config. text_colors , & ascii_colors) ;
239
241
240
242
Ok ( Info {
241
- git_version : git_v ,
242
- git_username : git_user ,
243
+ git_version,
244
+ git_username,
243
245
project_name : repository_name,
244
246
head_refs,
245
247
version,
@@ -277,36 +279,6 @@ impl Info {
277
279
output. lines ( ) . map ( |x| x. to_string ( ) ) . collect :: < Vec < _ > > ( )
278
280
}
279
281
280
- fn get_number_of_tags_branches ( dir : & str ) -> ( usize , usize ) {
281
- let tags = {
282
- let output = Command :: new ( "git" )
283
- . args ( vec ! [ "-C" , dir, "tag" ] )
284
- . output ( )
285
- . expect ( "Failed to execute git." ) ;
286
-
287
- let tags = String :: from_utf8_lossy ( & output. stdout ) ;
288
-
289
- tags. lines ( ) . count ( )
290
- } ;
291
-
292
- let branches = {
293
- let output = Command :: new ( "git" )
294
- . args ( vec ! [ "-C" , dir, "branch" , "-r" ] )
295
- . output ( )
296
- . expect ( "Failed to execute git." ) ;
297
-
298
- let branches = String :: from_utf8_lossy ( & output. stdout ) ;
299
-
300
- if branches. lines ( ) . count ( ) > 0 {
301
- branches. lines ( ) . count ( ) - 1 //Exclude origin/HEAD -> origin/master
302
- } else {
303
- 0
304
- }
305
- } ;
306
-
307
- ( tags, branches)
308
- }
309
-
310
282
fn get_authors ( git_history : & [ String ] , n : usize ) -> Vec < ( String , usize , usize ) > {
311
283
let mut authors = std:: collections:: HashMap :: new ( ) ;
312
284
let mut author_name_by_email = std:: collections:: HashMap :: new ( ) ;
@@ -339,21 +311,9 @@ impl Info {
339
311
authors
340
312
}
341
313
342
- fn get_git_version_and_username ( dir : & str ) -> ( String , String ) {
343
- let version =
344
- Command :: new ( "git" ) . arg ( "--version" ) . output ( ) . expect ( "Failed to execute git." ) ;
345
- let version = String :: from_utf8_lossy ( & version. stdout ) . replace ( '\n' , "" ) ;
346
-
347
- let username = Command :: new ( "git" )
348
- . arg ( "-C" )
349
- . arg ( dir)
350
- . arg ( "config" )
351
- . arg ( "--get" )
352
- . arg ( "user.name" )
353
- . output ( )
354
- . expect ( "Failed to execute git." ) ;
355
- let username = String :: from_utf8_lossy ( & username. stdout ) . replace ( '\n' , "" ) ;
356
- ( version, username)
314
+ fn get_git_version ( ) -> Result < String > {
315
+ let version = Command :: new ( "git" ) . arg ( "--version" ) . output ( ) ?;
316
+ Ok ( String :: from_utf8_lossy ( & version. stdout ) . replace ( '\n' , "" ) )
357
317
}
358
318
359
319
fn get_number_of_commits ( git_history : & [ String ] ) -> String {
0 commit comments