Skip to content

Commit

Permalink
feat(blame): add reblame at commit parent
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jul 16, 2024
1 parent 2a7b39f commit f4928ba
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lua/gitsigns/blame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,14 @@ end
--- @param blame table<integer,Gitsigns.BlameInfo?>
--- @param win integer
--- @param revision? string
local function reblame(blame, win, revision)
--- @param parent? boolean
local function reblame(blame, win, revision, parent)
local blm_win = api.nvim_get_current_win()
local lnum = unpack(api.nvim_win_get_cursor(blm_win))
local sha = blame[lnum].commit.sha
if parent then
sha = sha .. '^'
end
if sha == revision then
return
end
Expand Down Expand Up @@ -324,6 +328,13 @@ M.blame = function()
buffer = blm_bufnr,
})

vim.keymap.set('n', 'R', function()
reblame(blame, win, bcache.git_obj.revision, true)
end, {
desc = 'Reblame at commit parent',
buffer = blm_bufnr,
})

vim.keymap.set('n', 's', function()
show_commit(blm_win, 'vsplit', bcache)
end, {
Expand All @@ -340,6 +351,7 @@ M.blame = function()

menu('GitsignsBlame', {
{ 'Reblame at commit', 'r' },
{ 'Reblame at commit parent', 'R' },
{ 'Show commit (vsplit)', 's' },
{ ' (tab)', 'S' },
})
Expand Down

0 comments on commit f4928ba

Please sign in to comment.