refactor(git): consolidate sync subprocess pattern via util.system_sync
This commit is contained in:
+3
-10
@@ -38,22 +38,15 @@ function M.show(opts)
|
||||
table.insert(cmd, "--max-count=" .. max_count)
|
||||
end
|
||||
|
||||
local result = vim.system(cmd, { cwd = worktree, text = true }):wait()
|
||||
if result.code ~= 0 then
|
||||
log.error("git log failed: %s", vim.trim(result.stderr or ""))
|
||||
local stdout = util.system_sync(cmd, { cwd = worktree })
|
||||
if not stdout then
|
||||
return
|
||||
end
|
||||
|
||||
local buf = git.new_scratch()
|
||||
vim.b[buf].git_worktree = worktree
|
||||
vim.bo[buf].modifiable = true
|
||||
vim.api.nvim_buf_set_lines(
|
||||
buf,
|
||||
0,
|
||||
-1,
|
||||
false,
|
||||
util.split_lines(result.stdout or "")
|
||||
)
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, util.split_lines(stdout))
|
||||
vim.bo[buf].modifiable = false
|
||||
vim.bo[buf].modified = false
|
||||
vim.bo[buf].filetype = "gitlog"
|
||||
|
||||
Reference in New Issue
Block a user