mirror of
https://github.com/LazyVim/starter.git
synced 2026-07-24 13:31:04 +00:00
Branch fiels returns only files that exist
This commit is contained in:
parent
4e059e36c0
commit
c5daabc8d0
1 changed files with 11 additions and 1 deletions
|
|
@ -34,7 +34,17 @@ function M.branch_files(opts)
|
||||||
local diff_filter = include_deleted and "" or "--diff-filter=d"
|
local diff_filter = include_deleted and "" or "--diff-filter=d"
|
||||||
local git_cmd =
|
local git_cmd =
|
||||||
string.format("git diff --name-status %s %s...%s | awk '{print $2}'", diff_filter, base_branch, current_branch)
|
string.format("git diff --name-status %s %s...%s | awk '{print $2}'", diff_filter, base_branch, current_branch)
|
||||||
return vim.fn.systemlist(git_cmd)
|
local files = vim.fn.systemlist(git_cmd)
|
||||||
|
|
||||||
|
-- Filter the list to include only existing files
|
||||||
|
local existing_files = {}
|
||||||
|
for _, file in ipairs(files) do
|
||||||
|
if vim.loop.fs_stat(file) then
|
||||||
|
table.insert(existing_files, file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return existing_files
|
||||||
end
|
end
|
||||||
|
|
||||||
M.branch_files()
|
M.branch_files()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue