feat(picker.git): added all option to also list remote branched for git_branches. Closes #1465

This commit is contained in:
Folke Lemaitre 2025-03-01 09:48:28 +01:00
parent e591715b03
commit 3d695ab7d0
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 15 additions and 3 deletions

View file

@ -346,12 +346,16 @@ end
function M.git_checkout(picker, item)
picker:close()
if item then
local what = item.branch or item.commit
local what = item.branch or item.commit --[[@as string?]]
if not what then
Snacks.notify.warn("No branch or commit found", { title = "Snacks Picker" })
return
end
local cmd = { "git", "checkout", what }
local remote_branch = what:match("^remotes/[^/]+/(.+)$")
if remote_branch then
cmd = { "git", "checkout", "-b", remote_branch, what }
end
if item.file then
vim.list_extend(cmd, { "--", item.file })
end