mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
feat(picker.git_diff): add base option to show diff against a merge base. Useful to see changes on a branch/PR
This commit is contained in:
parent
b4e2384da9
commit
7964f040bf
2 changed files with 6 additions and 2 deletions
|
|
@ -333,7 +333,8 @@ M.git_status = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type snacks.picker.git.Config
|
---@class snacks.picker.git.diff.Config: snacks.picker.git.Config
|
||||||
|
---@field base? string base commit/branch/tag to diff against (default: HEAD)
|
||||||
M.git_diff = {
|
M.git_diff = {
|
||||||
finder = "git_diff",
|
finder = "git_diff",
|
||||||
format = "file",
|
format = "file",
|
||||||
|
|
|
||||||
|
|
@ -253,11 +253,14 @@ function M.status(opts, ctx)
|
||||||
}, ctx)
|
}, ctx)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param opts snacks.picker.git.Config
|
---@param opts snacks.picker.git.diff.Config
|
||||||
---@type snacks.picker.finder
|
---@type snacks.picker.finder
|
||||||
function M.diff(opts, ctx)
|
function M.diff(opts, ctx)
|
||||||
local args =
|
local args =
|
||||||
M.git("diff", "--no-color", "--no-ext-diff", { args = { "-c", "diff.noprefix=false", "--no-pager" } }, opts)
|
M.git("diff", "--no-color", "--no-ext-diff", { args = { "-c", "diff.noprefix=false", "--no-pager" } }, opts)
|
||||||
|
if opts.base then
|
||||||
|
vim.list_extend(args, { "--merge-base", opts.base })
|
||||||
|
end
|
||||||
local file, line ---@type string?, number?
|
local file, line ---@type string?, number?
|
||||||
local header, hunk = {}, {} ---@type string[], string[]
|
local header, hunk = {}, {} ---@type string[], string[]
|
||||||
local header_len = 4
|
local header_len = 4
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue