@@ -2,9 +2,11 @@ use std::{process::Command, rc::Rc};
22
33use crate :: {
44 Res ,
5- app:: { App , PromptParams , State } ,
6- item_data:: { ItemData , Rev } ,
5+ app:: { App , State } ,
6+ git,
7+ item_data:: ItemData ,
78 menu:: arg:: Arg ,
9+ picker:: { PickerParams , PickerState } ,
810 term:: Term ,
911} ;
1012
@@ -52,23 +54,23 @@ impl OpTrait for CherryPickContinue {
5254
5355pub ( crate ) struct CherryPick ;
5456impl OpTrait for CherryPick {
55- fn get_action ( & self , _target : & ItemData ) -> Option < Action > {
57+ fn get_action ( & self , target : & ItemData ) -> Option < Action > {
58+ let rev = target. rev ( ) ;
5659 Some ( Rc :: new ( move |app : & mut App , term : & mut Term | {
57- let commit = app. prompt (
60+ let result = app. pick (
5861 term,
59- & PromptParams {
60- prompt : "Cherry-pick commit" ,
61- create_default_value : Box :: new ( |app| {
62- selected_rev ( app)
63- . as_ref ( )
64- . map ( Rev :: shorthand)
65- . map ( String :: from)
66- } ) ,
67- ..Default :: default ( )
68- } ,
62+ PickerState :: with_refs ( PickerParams {
63+ prompt : "Cherry-pick" . into ( ) ,
64+ refs : & git:: branches_tags ( & app. state . repo ) ?,
65+ exclude_ref : git:: head_ref ( & app. state . repo ) ?,
66+ default : rev. clone ( ) . or_else ( || selected_rev ( app) ) ,
67+ allow_custom_input : true ,
68+ } ) ,
6969 ) ?;
7070
71- cherry_pick ( app, term, & commit) ?;
71+ if let Some ( data) = result {
72+ cherry_pick ( app, term, data. display ( ) ) ?;
73+ }
7274 Ok ( ( ) )
7375 } ) )
7476 }
0 commit comments