File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ use std:: collections:: HashMap ;
15
16
use std:: env;
16
17
use std:: error:: Error ;
17
18
use std:: process:: Command ;
@@ -211,12 +212,32 @@ fn select_commit_to_amend<'a>(
211
212
. map ( |rev| repo. find_commit ( rev) )
212
213
. collect :: < Result < Vec < _ > , _ > > ( ) ?
213
214
} ;
215
+ let branches: HashMap < Oid , String > = repo
216
+ . branches ( None ) ?
217
+ . filter_map ( |b| {
218
+ b. ok ( ) . and_then ( |( b, _type) | {
219
+ let name: Option < String > = b. name ( ) . ok ( ) . and_then ( |n| n. map ( |n| n. to_owned ( ) ) ) ;
220
+ let oid = b. into_reference ( ) . resolve ( ) . ok ( ) . and_then ( |r| r. target ( ) ) ;
221
+ name. and_then ( |name| oid. map ( |oid| ( oid, name) ) )
222
+ } )
223
+ } )
224
+ . collect ( ) ;
214
225
let rev_aliases = commits
215
226
. iter ( )
216
- . map ( |commit| {
227
+ . enumerate ( )
228
+ . map ( |( i, commit) | {
229
+ let bname = if i > 0 {
230
+ branches
231
+ . get ( & commit. id ( ) )
232
+ . map ( |n| format ! ( "({}) " , n) )
233
+ . unwrap_or_else ( String :: new)
234
+ } else {
235
+ String :: new ( )
236
+ } ;
217
237
format ! (
218
- "{} {}" ,
238
+ "{} {}{} " ,
219
239
& style( & commit. id( ) . to_string( ) [ 0 ..10 ] ) . blue( ) ,
240
+ style( bname) . green( ) ,
220
241
commit. summary( ) . unwrap_or( "no commit summary" )
221
242
)
222
243
} )
You can’t perform that action at this time.
0 commit comments