diff --git a/lua/neogit/buffers/commit_view/init.lua b/lua/neogit/buffers/commit_view/init.lua index 795f80871..c6c159688 100644 --- a/lua/neogit/buffers/commit_view/init.lua +++ b/lua/neogit/buffers/commit_view/init.lua @@ -6,6 +6,7 @@ local log = require("neogit.lib.git.log") local config = require("neogit.config") local CherryPickPopup = require("neogit.popups.cherry_pick") +local RevertPopup = require("neogit.popups.revert") local api = vim.api @@ -129,6 +130,9 @@ function M:open() ["A"] = function() CherryPickPopup.create { commits = { self.commit_info.oid } } end, + ["_"] = function() + RevertPopup.create { commits = { self.commit_info.oid } } + end, ["q"] = function() self:close() end, diff --git a/lua/neogit/buffers/log_view/init.lua b/lua/neogit/buffers/log_view/init.lua index af6ebd8c0..300009b50 100644 --- a/lua/neogit/buffers/log_view/init.lua +++ b/lua/neogit/buffers/log_view/init.lua @@ -81,7 +81,7 @@ function M:open() end, ["_"] = function() local stack = self.buffer.ui:get_component_stack_under_cursor() - RevertPopup.create(stack[#stack].options.oid) + RevertPopup.create { commits = { stack[#stack].options.oid } } end, [""] = function() local stack = self.buffer.ui:get_component_stack_under_cursor() diff --git a/lua/neogit/buffers/reflog_view/init.lua b/lua/neogit/buffers/reflog_view/init.lua index c5b994e91..63cfbe65b 100644 --- a/lua/neogit/buffers/reflog_view/init.lua +++ b/lua/neogit/buffers/reflog_view/init.lua @@ -77,7 +77,7 @@ function M:open() end, ["_"] = function() local stack = self.buffer.ui:get_component_stack_under_cursor() - RevertPopup.create(stack[#stack].options.oid) + RevertPopup.create { commits = { stack[#stack].options.oid } } end, [""] = function() local stack = self.buffer.ui:get_component_stack_under_cursor() diff --git a/lua/neogit/popups/revert/actions.lua b/lua/neogit/popups/revert/actions.lua index 3a3240593..227dccd5a 100644 --- a/lua/neogit/popups/revert/actions.lua +++ b/lua/neogit/popups/revert/actions.lua @@ -1,5 +1,4 @@ local a = require("plenary.async") -local status = require("neogit.status") local git = require("neogit.lib.git") local CommitSelectViewBuffer = require("neogit.buffers.commit_select_view") @@ -28,7 +27,7 @@ function M.commits(popup) git.revert.commits(commits, popup:get_arguments()) a.util.scheduler() - status.refresh(true, "revert_commits") + require("neogit.status").refresh(true, "revert_commits") end return M diff --git a/lua/neogit/popups/revert/init.lua b/lua/neogit/popups/revert/init.lua index 5f484cf89..f443217b8 100644 --- a/lua/neogit/popups/revert/init.lua +++ b/lua/neogit/popups/revert/init.lua @@ -3,7 +3,7 @@ local popup = require("neogit.lib.popup") local M = {} -function M.create(commits) +function M.create(env) -- TODO: enabled = true needs to check if incompatible switch is toggled in internal state, and not apply. -- if you enable 'no edit', and revert, next time you load the popup both will be enabled -- @@ -19,7 +19,7 @@ function M.create(commits) :switch("E", "no-edit", "Don't edit commit messages", { incompatible = { "edit" } }) :action("_", "Revert commit", actions.commits) -- TODO: Support multiple commits :action("v", "Revert changes") - :env({ commits = commits or {} }) + :env({ commits = env.commits or {} }) :build() p:show() diff --git a/lua/neogit/status.lua b/lua/neogit/status.lua index 736dbe37e..7181c3154 100644 --- a/lua/neogit/status.lua +++ b/lua/neogit/status.lua @@ -1131,7 +1131,7 @@ local cmd_func_map = function() end, ["RevertPopup"] = function() local line = M.status_buffer:get_current_line() - require("neogit.popups.revert").create { line[1]:match("^(%x%x%x%x%x%x%x+)") } + require("neogit.popups.revert").create { commits = { line[1]:match("^(%x%x%x%x%x%x%x+)") } } end, ["BranchPopup"] = require("neogit.popups.branch").create, ["FetchPopup"] = require("neogit.popups.fetch").create,