refactor(git): make the git module self-contained under git.util

This commit is contained in:
2026-04-28 09:05:01 +02:00
parent 4390b55dfe
commit 37e5582795
10 changed files with 195 additions and 75 deletions
+4 -5
View File
@@ -1,6 +1,5 @@
local editor = require("git.editor")
local git = require("git")
local log = require("log")
local repo = require("git.repo")
local M = {}
@@ -10,7 +9,7 @@ function M.commit(opts)
local amend = opts and opts.amend or false
local _, worktree = repo.resolve_cwd()
if not worktree then
log.warning("not in a git repository")
util.warning("not in a git repository")
return
end
@@ -46,7 +45,7 @@ function M.commit(opts)
local out = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
local fw, werr = io.open(file_path, "w")
if not fw then
log.error("failed to write %s: %s", file_path, werr or "")
util.error("failed to write %s: %s", file_path, werr or "")
return
end
fw:write(table.concat(out, "\n"))
@@ -68,12 +67,12 @@ function M.commit(opts)
vim.api.nvim_buf_delete(proxy_buf, { force = true })
end
if result.code ~= 0 then
log.error("git commit failed: %s", vim.trim(result.stderr or ""))
util.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)
util.info("%s", out)
end
end)
end