1
1
use anyhow:: { anyhow, Result } ;
2
+ use console:: style;
2
3
use gix:: state:: InProgress ;
3
4
use gix:: {
4
5
sec:: { self , trust:: DefaultForLevel } ,
5
6
Repository , ThreadSafeRepository ,
6
7
} ;
7
8
use log:: debug;
9
+ use std:: process:: Command ;
8
10
use std:: { path:: PathBuf , process:: exit} ;
9
11
10
12
pub struct Repo {
@@ -29,20 +31,62 @@ pub struct Repo {
29
31
30
32
fn main ( ) {
31
33
env_logger:: init ( ) ;
34
+
32
35
let path = PathBuf :: from ( "." ) ;
33
36
34
- match get_output ( path) {
35
- Ok ( output) => println ! ( "{ output}" ) ,
37
+ let s = match get_output ( path) {
38
+ Ok ( output) => output,
36
39
Err ( e) => {
37
40
debug ! ( "{e}" ) ;
38
41
exit ( 1 ) ;
39
42
}
40
43
} ;
44
+
45
+ let cmd = Command :: new ( "git" )
46
+ . arg ( "status" )
47
+ . arg ( "--porcelain" )
48
+ . output ( )
49
+ . ok ( ) ;
50
+
51
+ if let Some ( cmd) = cmd {
52
+ if cmd. status . success ( ) {
53
+ let out = String :: from_utf8_lossy ( & cmd. stdout ) ;
54
+ let out = out
55
+ . trim ( )
56
+ . split ( '\n' )
57
+ . map ( |x| x. rsplit_once ( " " ) . map ( |x| x. 0 . trim ( ) ) ) ;
58
+
59
+ match out {
60
+ _ => {
61
+ for i in out {
62
+ match i {
63
+ None => {
64
+ println ! ( "{}" , style( s) . green( ) ) ;
65
+ break ;
66
+ }
67
+ Some ( "M" ) => {
68
+ println ! ( "{}" , style( & s) . red( ) ) ;
69
+ break ;
70
+ }
71
+ Some ( "??" ) => {
72
+ println ! ( "{}" , style( & s) . magenta( ) . bold( ) ) ;
73
+ break ;
74
+ }
75
+ _ => continue ,
76
+ }
77
+ }
78
+ }
79
+ }
80
+ } else {
81
+ println ! ( "{s}" )
82
+ }
83
+ }
41
84
}
42
85
43
86
fn get_output ( path : PathBuf ) -> Result < String > {
44
87
// custom open options
45
88
let repo = get_repo ( path) ?;
89
+
46
90
let git_repo = repo. repo . to_thread_local ( ) ;
47
91
48
92
let display_name = repo
@@ -113,6 +157,8 @@ fn get_repo(path: PathBuf) -> Result<Repo> {
113
157
// let remote = get_remote_repository_info(&repository, branch.as_deref());
114
158
let path = repository. path ( ) . to_path_buf ( ) ;
115
159
160
+ // let fs_monitor_value_is_true = repository;
161
+
116
162
let repo = Repo {
117
163
repo : shared_repo,
118
164
branch,
0 commit comments