@@ -2,6 +2,26 @@ local M = {}
2
2
3
3
local telescope = require ' telescope.builtin'
4
4
5
+ local cherryPickCommitsFromBranch = function (_ , action )
6
+ action (' i' , ' <CR>' , function (prompt_bufnr )
7
+ local selection = require (' telescope.actions.state' ).get_selected_entry ()
8
+ require (' telescope.actions' ).close (prompt_bufnr )
9
+ -- start a telescope listing commits of this branch
10
+ telescope .git_commits {
11
+ branch = selection .value ,
12
+ attach_mappings = function (_ , action )
13
+ action (' i' , ' <CR>' , function (prompt_bufnr )
14
+ local commit = require (' telescope.actions.state' ).get_selected_entry ()
15
+ require (' telescope.actions' ).close (prompt_bufnr )
16
+ vim .cmd (' Git cherry-pick ' .. commit .value .. ' -x' )
17
+ end )
18
+ return true
19
+ end ,
20
+ }
21
+ end )
22
+ return true
23
+ end
24
+
5
25
local openDiffView = function (_ , action )
6
26
action (' i' , ' <CR>' , function (prompt_bufnr )
7
27
local selection = require (' telescope.actions.state' ).get_selected_entry ()
@@ -78,6 +98,12 @@ M.git_menu = { --{{{
78
98
text = ' Checkout branch' ,
79
99
handler = telescope .git_branches ,
80
100
},
101
+ {
102
+ text = ' Cherry-Pick ▶' ,
103
+ handler = function ()
104
+ telescope .git_branches { attach_mappings = cherryPickCommitsFromBranch }
105
+ end ,
106
+ },
81
107
{
82
108
text = ' Stash changes ▶' ,
83
109
options = {
0 commit comments