refactor(git): convert blocking subprocess calls to async
This commit is contained in:
+20
-14
@@ -67,20 +67,26 @@ function M.commit(opts)
|
||||
if amend then
|
||||
table.insert(cmd, "--amend")
|
||||
end
|
||||
local result = vim.system(cmd, { cwd = worktree, text = true })
|
||||
:wait()
|
||||
if result.code ~= 0 then
|
||||
log.error(
|
||||
"git commit failed: %s",
|
||||
vim.trim(result.stderr or "")
|
||||
)
|
||||
return
|
||||
end
|
||||
local out = vim.trim(result.stdout or "")
|
||||
if out ~= "" then
|
||||
log.info("%s", out)
|
||||
end
|
||||
vim.api.nvim_buf_delete(buf, { force = true })
|
||||
vim.system(
|
||||
cmd,
|
||||
{ cwd = worktree, text = true },
|
||||
vim.schedule_wrap(function(result)
|
||||
if result.code ~= 0 then
|
||||
log.error(
|
||||
"git commit failed: %s",
|
||||
vim.trim(result.stderr or "")
|
||||
)
|
||||
return
|
||||
end
|
||||
local out = vim.trim(result.stdout or "")
|
||||
if out ~= "" then
|
||||
log.info("%s", out)
|
||||
end
|
||||
if vim.api.nvim_buf_is_valid(buf) then
|
||||
vim.api.nvim_buf_delete(buf, { force = true })
|
||||
end
|
||||
end)
|
||||
)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user