11use anyhow:: { anyhow, Result } ;
2+ use console:: style;
23use gix:: state:: InProgress ;
34use gix:: {
45 sec:: { self , trust:: DefaultForLevel } ,
56 Repository , ThreadSafeRepository ,
67} ;
78use log:: debug;
9+ use std:: process:: Command ;
810use std:: { path:: PathBuf , process:: exit} ;
911
1012pub struct Repo {
@@ -29,20 +31,62 @@ pub struct Repo {
2931
3032fn main ( ) {
3133 env_logger:: init ( ) ;
34+
3235 let path = PathBuf :: from ( "." ) ;
3336
34- match get_output ( path) {
35- Ok ( output) => println ! ( "{ output}" ) ,
37+ let s = match get_output ( path) {
38+ Ok ( output) => output,
3639 Err ( e) => {
3740 debug ! ( "{e}" ) ;
3841 exit ( 1 ) ;
3942 }
4043 } ;
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+ }
4184}
4285
4386fn get_output ( path : PathBuf ) -> Result < String > {
4487 // custom open options
4588 let repo = get_repo ( path) ?;
89+
4690 let git_repo = repo. repo . to_thread_local ( ) ;
4791
4892 let display_name = repo
@@ -113,6 +157,8 @@ fn get_repo(path: PathBuf) -> Result<Repo> {
113157 // let remote = get_remote_repository_info(&repository, branch.as_deref());
114158 let path = repository. path ( ) . to_path_buf ( ) ;
115159
160+ // let fs_monitor_value_is_true = repository;
161+
116162 let repo = Repo {
117163 repo : shared_repo,
118164 branch,
0 commit comments