Skip to content

Commit 868266d

Browse files
authored
Merge pull request #560 from NeogitOrg/more-revert
2 parents 4ed8336 + 3c8b892 commit 868266d

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

lua/neogit/buffers/commit_view/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local log = require("neogit.lib.git.log")
66
local config = require("neogit.config")
77

88
local CherryPickPopup = require("neogit.popups.cherry_pick")
9+
local RevertPopup = require("neogit.popups.revert")
910

1011
local api = vim.api
1112

@@ -129,6 +130,9 @@ function M:open()
129130
["A"] = function()
130131
CherryPickPopup.create { commits = { self.commit_info.oid } }
131132
end,
133+
["_"] = function()
134+
RevertPopup.create { commits = { self.commit_info.oid } }
135+
end,
132136
["q"] = function()
133137
self:close()
134138
end,

lua/neogit/buffers/log_view/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function M:open()
8181
end,
8282
["_"] = function()
8383
local stack = self.buffer.ui:get_component_stack_under_cursor()
84-
RevertPopup.create(stack[#stack].options.oid)
84+
RevertPopup.create { commits = { stack[#stack].options.oid } }
8585
end,
8686
["<enter>"] = function()
8787
local stack = self.buffer.ui:get_component_stack_under_cursor()

lua/neogit/buffers/reflog_view/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function M:open()
7777
end,
7878
["_"] = function()
7979
local stack = self.buffer.ui:get_component_stack_under_cursor()
80-
RevertPopup.create(stack[#stack].options.oid)
80+
RevertPopup.create { commits = { stack[#stack].options.oid } }
8181
end,
8282
["<enter>"] = function()
8383
local stack = self.buffer.ui:get_component_stack_under_cursor()

lua/neogit/popups/revert/actions.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
local a = require("plenary.async")
2-
local status = require("neogit.status")
32
local git = require("neogit.lib.git")
43
local CommitSelectViewBuffer = require("neogit.buffers.commit_select_view")
54

@@ -28,7 +27,7 @@ function M.commits(popup)
2827

2928
git.revert.commits(commits, popup:get_arguments())
3029
a.util.scheduler()
31-
status.refresh(true, "revert_commits")
30+
require("neogit.status").refresh(true, "revert_commits")
3231
end
3332

3433
return M

lua/neogit/popups/revert/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local popup = require("neogit.lib.popup")
33

44
local M = {}
55

6-
function M.create(commits)
6+
function M.create(env)
77
-- TODO: enabled = true needs to check if incompatible switch is toggled in internal state, and not apply.
88
-- if you enable 'no edit', and revert, next time you load the popup both will be enabled
99
--
@@ -19,7 +19,7 @@ function M.create(commits)
1919
:switch("E", "no-edit", "Don't edit commit messages", { incompatible = { "edit" } })
2020
:action("_", "Revert commit", actions.commits) -- TODO: Support multiple commits
2121
:action("v", "Revert changes")
22-
:env({ commits = commits or {} })
22+
:env({ commits = env.commits or {} })
2323
:build()
2424

2525
p:show()

lua/neogit/status.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ local cmd_func_map = function()
11311131
end,
11321132
["RevertPopup"] = function()
11331133
local line = M.status_buffer:get_current_line()
1134-
require("neogit.popups.revert").create { line[1]:match("^(%x%x%x%x%x%x%x+)") }
1134+
require("neogit.popups.revert").create { commits = { line[1]:match("^(%x%x%x%x%x%x%x+)") } }
11351135
end,
11361136
["BranchPopup"] = require("neogit.popups.branch").create,
11371137
["FetchPopup"] = require("neogit.popups.fetch").create,

0 commit comments

Comments
 (0)