@@ -27,6 +27,7 @@ pub struct Info {
27
27
last_change : String ,
28
28
repo : String ,
29
29
commits : String ,
30
+ pending : String ,
30
31
repo_size : String ,
31
32
number_of_lines : usize ,
32
33
license : String ,
@@ -86,6 +87,14 @@ impl std::fmt::Display for Info {
86
87
) ?;
87
88
}
88
89
90
+ if !self . disable_fields . pending && self . pending != "" {
91
+ write_buf (
92
+ & mut buf,
93
+ & self . get_formatted_info_label ( "Pending: " , color) ,
94
+ & self . pending ,
95
+ ) ?;
96
+ }
97
+
89
98
if !self . disable_fields . version {
90
99
write_buf (
91
100
& mut buf,
@@ -304,6 +313,7 @@ impl Info {
304
313
let ( git_v, git_user) = Info :: get_git_info ( workdir_str) ;
305
314
let version = Info :: get_version ( workdir_str) ?;
306
315
let commits = Info :: get_commits ( workdir_str, no_merges) ?;
316
+ let pending = Info :: get_pending_pending ( workdir_str) ?;
307
317
let repo_size = Info :: get_packed_size ( workdir_str) ?;
308
318
let last_change = Info :: get_last_change ( workdir_str) ?;
309
319
let creation_date = Info :: get_creation_time ( workdir_str) ?;
@@ -324,6 +334,7 @@ impl Info {
324
334
last_change,
325
335
repo : config. repository_url ,
326
336
commits,
337
+ pending,
327
338
repo_size,
328
339
number_of_lines,
329
340
license : project_license,
@@ -502,6 +513,54 @@ impl Info {
502
513
}
503
514
}
504
515
516
+ fn get_pending_pending ( dir : & str ) -> Result < String > {
517
+ let output = Command :: new ( "git" )
518
+ . arg ( "-C" )
519
+ . arg ( dir)
520
+ . arg ( "status" )
521
+ . arg ( "--porcelain" )
522
+ . output ( )
523
+ . expect ( "Failed to execute git." ) ;
524
+
525
+ let output = String :: from_utf8_lossy ( & output. stdout ) ;
526
+
527
+ if output == "" {
528
+ Ok ( "" . into ( ) )
529
+ } else {
530
+ let lines = output. lines ( ) ;
531
+
532
+ let mut deleted = 0 ;
533
+ let mut added = 0 ;
534
+ let mut modified = 0 ;
535
+
536
+ for line in lines {
537
+ let prefix = & line[ ..2 ] ;
538
+
539
+ match prefix. trim ( ) {
540
+ "D" => deleted += 1 ,
541
+ "A" | "AM" | "??" => added += 1 ,
542
+ "M" | "MM" | "R" => modified += 1 ,
543
+ _ => { }
544
+ }
545
+ }
546
+
547
+ let mut result = String :: from ( "" ) ;
548
+ if modified > 0 {
549
+ result = format ! ( "{}+-" , modified)
550
+ }
551
+
552
+ if added > 0 {
553
+ result = format ! ( "{} {}+" , result, added) ;
554
+ }
555
+
556
+ if deleted > 0 {
557
+ result = format ! ( "{} {}-" , result, deleted) ;
558
+ }
559
+
560
+ Ok ( result. into ( ) )
561
+ }
562
+ }
563
+
505
564
fn get_packed_size ( dir : & str ) -> Result < String > {
506
565
let output = Command :: new ( "git" )
507
566
. arg ( "-C" )
0 commit comments