@@ -36,6 +36,7 @@ struct Info {
36
36
last_change : String ,
37
37
repo : String ,
38
38
commits : String ,
39
+ repo_size : String ,
39
40
number_of_lines : usize ,
40
41
license : String ,
41
42
}
@@ -130,6 +131,12 @@ impl fmt::Display for Info {
130
131
"Lines of code: " . color( color) . bold( ) ,
131
132
self . number_of_lines
132
133
) ?;
134
+ writeln ! (
135
+ buffer,
136
+ "{}{}" ,
137
+ "Repository size: " . color( color) . bold( ) ,
138
+ self . repo_size
139
+ ) ?;
133
140
writeln ! (
134
141
buffer,
135
142
"{}{}" ,
@@ -339,6 +346,7 @@ fn main() -> Result<()> {
339
346
let config = get_configuration ( & dir) ?;
340
347
let version = get_version ( & dir) ?;
341
348
let commits = get_commits ( & dir) ?;
349
+ let repo_size = get_packed_size ( & dir) ?;
342
350
let last_change = get_last_change ( & dir) ?;
343
351
344
352
let info = Info {
@@ -351,6 +359,7 @@ fn main() -> Result<()> {
351
359
last_change,
352
360
repo : config. repository_url ,
353
361
commits,
362
+ repo_size,
354
363
number_of_lines : get_total_loc ( & tokei_langs) ,
355
364
license : project_license ( & dir) ?,
356
365
} ;
@@ -472,6 +481,26 @@ fn get_commits(dir: &str) -> Result<String> {
472
481
}
473
482
}
474
483
484
+ fn get_packed_size ( dir : & str ) -> Result < String > {
485
+ let output = Command :: new ( "git" )
486
+ . arg ( "-C" )
487
+ . arg ( dir)
488
+ . arg ( "count-objects" )
489
+ . arg ( "-vH" )
490
+ . output ( )
491
+ . expect ( "Failed to execute git." ) ;
492
+
493
+ let output = String :: from_utf8_lossy ( & output. stdout ) ;
494
+ let lines = output. to_string ( ) ;
495
+ let size_line = lines. split ( "\n " ) . find ( |line| {
496
+ line. starts_with ( "size-pack:" )
497
+ } ) ;
498
+ match size_line {
499
+ None => Ok ( "??" . into ( ) ) ,
500
+ Some ( size_str) => Ok ( size_str[ 11 ..] . into ( ) )
501
+ }
502
+ }
503
+
475
504
fn is_git_installed ( ) -> bool {
476
505
Command :: new ( "git" )
477
506
. arg ( "--version" )
0 commit comments