fix(git): add env option for util.exec

This commit is contained in:
2026-05-09 00:02:44 +02:00
parent b9601ca4c4
commit 76de90f982
+7
View File
@@ -192,6 +192,7 @@ end
---@field cwd string? ---@field cwd string?
---@field stdin string? ---@field stdin string?
---@field silent boolean? ---@field silent boolean?
---@field env table<string, string>?
---@field on_exit fun(result: vim.SystemCompleted)? ---@field on_exit fun(result: vim.SystemCompleted)?
---@param cmd string[] ---@param cmd string[]
@@ -222,10 +223,16 @@ function M.exec(cmd, opts)
return result.stdout or "" return result.stdout or ""
end end
M.DEFAULT_GIT_ENV = {
GIT_TERMINAL_PROMPT = "false",
}
---@param args string[] ---@param args string[]
---@param opts ow.Git.Util.ExecOpts? ---@param opts ow.Git.Util.ExecOpts?
---@return string? ---@return string?
function M.git(args, opts) function M.git(args, opts)
opts = opts or {}
opts.env = vim.tbl_extend("force", M.DEFAULT_GIT_ENV, opts.env or {})
local cmd = { "git" } local cmd = { "git" }
vim.list_extend(cmd, args) vim.list_extend(cmd, args)
return M.exec(cmd, opts) return M.exec(cmd, opts)