@@ -93,6 +93,7 @@ pub fn process_repo_with_refs(dir: &str, refs: &[&str], user_branch: Option<&str
93
93
branches. push ( BranchInfo {
94
94
name : branch. to_string ( ) ,
95
95
relative_time : time. to_string ( ) ,
96
+ last_commit_hash : sha. to_string ( ) ,
96
97
ahead,
97
98
behind,
98
99
} ) ;
@@ -115,48 +116,55 @@ pub fn print_branch_table(branches: &[BranchInfo]) {
115
116
let mut max_behind = "Behind" . len ( ) ;
116
117
let mut max_name = "Branch" . len ( ) ;
117
118
let mut max_time = "Last Commit" . len ( ) ;
118
-
119
+ let mut max_hash = "Commit" . len ( ) ;
119
120
for b in branches {
120
121
max_ahead = max_ahead. max ( b. ahead . to_string ( ) . len ( ) ) ;
121
122
max_behind = max_behind. max ( b. behind . to_string ( ) . len ( ) ) ;
122
123
max_name = max_name. max ( b. name . len ( ) ) ;
123
124
max_time = max_time. max ( b. relative_time . len ( ) ) ;
125
+ max_hash = max_hash. max ( b. last_commit_hash . len ( ) ) ;
124
126
}
125
127
126
128
println ! (
127
- "{}{:>width_a$}{} {}{:>width_b$}{} {}{:<width_n$}{} {}{:<width_t$}{}" ,
129
+ "{}{:>width_a$}{} {}{:>width_b$}{} {}{:<width_n$}{} {}{:<width_h$}{} {}{:< width_t$}{}" ,
128
130
GREEN , "Ahead" , NO_COLOR ,
129
131
RED , "Behind" , NO_COLOR ,
130
132
BLUE , "Branch" , NO_COLOR ,
133
+ NO_COLOR , "Commit" , NO_COLOR ,
131
134
YELLOW , "Last Commit" , NO_COLOR ,
135
+ width_h = max_hash,
132
136
width_a = max_ahead,
133
137
width_b = max_behind,
134
138
width_n = max_name,
135
139
width_t = max_time,
136
140
) ;
137
141
138
142
println ! (
139
- "{}{:->width_a$}{} {}{:->width_b$}{} {}{:->width_n$}{} {}{:->width_t$}{}" ,
143
+ "{}{:->width_a$}{} {}{:->width_b$}{} {}{:->width_n$}{} {}{:->width_h$}{} {}{:-> width_t$}{}" ,
140
144
GREEN , "" , NO_COLOR ,
141
145
RED , "" , NO_COLOR ,
142
146
BLUE , "" , NO_COLOR ,
147
+ NO_COLOR , "" , NO_COLOR ,
143
148
YELLOW , "" , NO_COLOR ,
144
149
width_a = max_ahead,
145
150
width_b = max_behind,
146
151
width_n = max_name,
152
+ width_h = max_hash,
147
153
width_t = max_time,
148
154
) ;
149
155
150
156
for b in branches {
151
157
println ! (
152
- "{}{:>width_a$}{} {}{:>width_b$}{} {}{:<width_n$}{} {}{:<width_t$}{}" ,
158
+ "{}{:>width_a$}{} {}{:>width_b$}{} {}{:<width_n$}{} {}{:<width_h$}{} {}{:< width_t$}{}" ,
153
159
GREEN , b. ahead, NO_COLOR ,
154
160
RED , b. behind, NO_COLOR ,
155
161
BLUE , b. name, NO_COLOR ,
162
+ NO_COLOR , b. last_commit_hash, NO_COLOR ,
156
163
YELLOW , b. relative_time, NO_COLOR ,
157
164
width_a = max_ahead,
158
165
width_b = max_behind,
159
166
width_n = max_name,
167
+ width_h = max_hash,
160
168
width_t = max_time,
161
169
) ;
162
170
}
0 commit comments