From 0d5861f80dd0490d9b2420d122731d63af2b5edc Mon Sep 17 00:00:00 2001 From: Hanchin Hsieh Date: Tue, 25 Feb 2025 17:03:30 +0800 Subject: [PATCH] feat: add Windows support for git directory scanning (#1391) --- lua/avante/utils/init.lua | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index 11a7f22..97c9700 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -715,14 +715,27 @@ function M.scan_directory(options) if not cmd then local p = Path:new(options.directory) if p:joinpath(".git"):exists() and vim.fn.executable("git") == 1 then - cmd = { - "bash", - "-c", - string.format( - "cd %s && cat <(git ls-files --exclude-standard) <(git ls-files --exclude-standard --others)", - options.directory - ), - } + if vim.fn.has("win32") == 1 then + cmd = { + "powershell", + "-NoProfile", + "-NonInteractive", + "-Command", + string.format( + "Push-Location '%s'; (git ls-files --exclude-standard), (git ls-files --exclude-standard --others)", + options.directory:gsub("/", "\\") + ), + } + else + cmd = { + "bash", + "-c", + string.format( + "cd %s && cat <(git ls-files --exclude-standard) <(git ls-files --exclude-standard --others)", + options.directory + ), + } + end cmd_supports_max_depth = false else M.error("No search command found")