@@ -526,6 +526,42 @@ actions.git_rebase_branch = function(prompt_bufnr)
526
526
end
527
527
end
528
528
529
+ local git_reset_branch = function (prompt_bufnr , mode )
530
+ local cwd = action_state .get_current_picker (prompt_bufnr ).cwd
531
+ local selection = action_state .get_selected_entry ()
532
+
533
+ local confirmation = vim .fn .input (" Do you really wanna " .. mode .. " reset to " .. selection .value .. " ? [Y/n] " )
534
+ if confirmation ~= " " and string.lower (confirmation ) ~= " y" then
535
+ return
536
+ end
537
+
538
+ actions .close (prompt_bufnr )
539
+ local _ , ret , stderr = utils .get_os_command_output ({ " git" , " reset" , mode , selection .value }, cwd )
540
+ if ret == 0 then
541
+ print (" Reset to: " .. selection .value )
542
+ else
543
+ print (string.format (' Error when resetting to: %s. Git returned: "%s"' , selection .value , table.concat (stderr , " " )))
544
+ end
545
+ end
546
+
547
+ --- Reset to selected git commit using mixed mode
548
+ --- @param prompt_bufnr number : The prompt bufnr
549
+ actions .git_reset_mixed = function (prompt_bufnr )
550
+ git_reset_branch (prompt_bufnr , " --mixed" )
551
+ end
552
+
553
+ --- Reset to selected git commit using soft mode
554
+ --- @param prompt_bufnr number : The prompt bufnr
555
+ actions .git_reset_soft = function (prompt_bufnr )
556
+ git_reset_branch (prompt_bufnr , " --soft" )
557
+ end
558
+
559
+ --- Reset to selected git commit using hard mode
560
+ --- @param prompt_bufnr number : The prompt bufnr
561
+ actions .git_reset_hard = function (prompt_bufnr )
562
+ git_reset_branch (prompt_bufnr , " --hard" )
563
+ end
564
+
529
565
actions .git_checkout_current_buffer = function (prompt_bufnr )
530
566
local cwd = actions .get_current_picker (prompt_bufnr ).cwd
531
567
local selection = actions .get_selected_entry ()
0 commit comments