@@ -2,6 +2,26 @@ local M = {}
22
33local telescope = require ' telescope.builtin'
44
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+
525local openDiffView = function (_ , action )
626 action (' i' , ' <CR>' , function (prompt_bufnr )
727 local selection = require (' telescope.actions.state' ).get_selected_entry ()
@@ -78,6 +98,12 @@ M.git_menu = { --{{{
7898 text = ' Checkout branch' ,
7999 handler = telescope .git_branches ,
80100 },
101+ {
102+ text = ' Cherry-Pick ▶' ,
103+ handler = function ()
104+ telescope .git_branches { attach_mappings = cherryPickCommitsFromBranch }
105+ end ,
106+ },
81107 {
82108 text = ' Stash changes ▶' ,
83109 options = {
0 commit comments