mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(git_log): add author filter (#1091)
## Description I was using LazyGit feature to filter git logs by the author, unfortunately it was missing in snacks picker. Here is my solution to it. Let me know if you have better suggestion :) --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
parent
f32002607a
commit
8c1166165b
2 changed files with 6 additions and 0 deletions
|
@ -269,6 +269,7 @@ M.git_grep = {
|
|||
---@field follow? boolean track file history across renames
|
||||
---@field current_file? boolean show current file log
|
||||
---@field current_line? boolean show current line log
|
||||
---@field author? string filter commits by author
|
||||
M.git_log = {
|
||||
finder = "git_log",
|
||||
format = "git_log",
|
||||
|
|
|
@ -100,6 +100,10 @@ function M.log(opts, ctx)
|
|||
"--no-patch"
|
||||
)
|
||||
|
||||
if opts.author then
|
||||
table.insert(args, "--author=" .. opts.author)
|
||||
end
|
||||
|
||||
local file ---@type string?
|
||||
if opts.current_line then
|
||||
local cursor = vim.api.nvim_win_get_cursor(ctx.filter.current_win)
|
||||
|
@ -118,6 +122,7 @@ function M.log(opts, ctx)
|
|||
|
||||
local Proc = require("snacks.picker.source.proc")
|
||||
file = file and vim.fs.normalize(file) or nil
|
||||
|
||||
local cwd = vim.fs.normalize(file and vim.fn.fnamemodify(file, ":h") or opts and opts.cwd or uv.cwd() or ".") or nil
|
||||
cwd = Snacks.git.get_root(cwd) or cwd
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue