File tree 1 file changed +36
-3
lines changed
1 file changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -508,10 +508,43 @@ fn get_packed_size(dir: &str) -> Result<String> {
508
508
let size_line = lines. split ( "\n " ) . find ( |line| {
509
509
line. starts_with ( "size-pack:" )
510
510
} ) ;
511
- match size_line {
512
- None => Ok ( "??" . into ( ) ) ,
513
- Some ( size_str) => Ok ( size_str[ 11 ..] . into ( ) )
511
+
512
+ let repo_size = match size_line {
513
+ None => "??" ,
514
+ Some ( size_str) => & ( size_str[ 11 ..] )
515
+ } ;
516
+
517
+ let output = Command :: new ( "git" )
518
+ . arg ( "-C" )
519
+ . arg ( dir)
520
+ . arg ( "ls-files" )
521
+ . output ( )
522
+ . expect ( "Failed to execute git." ) ;
523
+ // To check if command executed successfully or not
524
+ let error = & output. stderr ;
525
+
526
+ if error. is_empty ( ) {
527
+ let output = String :: from_utf8_lossy ( & output. stdout ) ;
528
+
529
+ let lines = output. to_string ( ) ;
530
+ let files_list = lines. split ( "\n " ) ;
531
+ let mut files_count: u128 = 0 ;
532
+ for file in files_list {
533
+ files_count+=1 ;
534
+ }
535
+ files_count-=1 ; // As splitting giving one line extra(blank).
536
+ let res = repo_size. to_owned ( ) + & ( " (" ) + & ( files_count. to_string ( ) ) + & ( " files)" ) ;
537
+ Ok ( res. into ( ) )
514
538
}
539
+ else {
540
+ let mut res: & str ;
541
+ if repo_size == "??" {
542
+ res = "??" ;
543
+ } else {
544
+ res = repo_size;
545
+ }
546
+ Ok ( res. into ( ) )
547
+ }
515
548
}
516
549
517
550
fn is_git_installed ( ) -> bool {
You can’t perform that action at this time.
0 commit comments