feat: add git reset action for git commits picker (#999)

This commit is contained in:
Joel Palmer
2021-07-29 16:16:45 -05:00
committed by GitHub
parent 82f4d3028b
commit b742c50bf1
4 changed files with 47 additions and 2 deletions

View File

@@ -65,8 +65,14 @@ git.commits = function(opts)
previewers.git_commit_message.new(opts),
},
sorter = conf.file_sorter(opts),
attach_mappings = function()
attach_mappings = function(_, map)
actions.select_default:replace(actions.git_checkout)
map("i", "<c-r>m", actions.git_reset_mixed)
map("n", "<c-r>m", actions.git_reset_mixed)
map("i", "<c-r>s", actions.git_reset_soft)
map("n", "<c-r>s", actions.git_reset_soft)
map("i", "<c-r>h", actions.git_reset_hard)
map("n", "<c-r>h", actions.git_reset_hard)
return true
end,
}):find()

View File

@@ -144,6 +144,9 @@ builtin.git_files = require("telescope.builtin.git").files
--- Lists commits for current directory with diff preview
--- - Default keymaps:
--- - `<cr>`: checks out the currently selected commit
--- - `<C-r>m`: resets current branch to selected commit using mixed mode
--- - `<C-r>s`: resets current branch to selected commit using soft mode
--- - `<C-r>h`: resets current branch to selected commit using hard mode
---@param opts table: options to pass to the picker
---@field cwd string: specify the path of the repo
builtin.git_commits = require("telescope.builtin.git").commits