refactor(git): make the git module self-contained under git.util
This commit is contained in:
+8
-6
@@ -1,5 +1,4 @@
|
||||
local log = require("log")
|
||||
local util = require("util")
|
||||
local util = require("git.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -76,7 +75,7 @@ function M.resolve(path)
|
||||
f:close()
|
||||
local gitdir = content:match("gitdir:%s*(%S+)")
|
||||
if not gitdir then
|
||||
log.warning(".git file at %s has no `gitdir:` line", found)
|
||||
util.warning(".git file at %s has no `gitdir:` line", found)
|
||||
return nil
|
||||
end
|
||||
if not gitdir:match("^/") then
|
||||
@@ -104,7 +103,7 @@ end
|
||||
---@field buffers table<integer, true> set of registered buffer numbers
|
||||
---@field watcher? uv.uv_fs_event_t
|
||||
---@field refresh fun(self: ow.Git.Repo)
|
||||
---@field refresh_handle ow.Util.DebounceHandle
|
||||
---@field refresh_handle ow.Git.Util.DebounceHandle
|
||||
local Repo = {}
|
||||
Repo.__index = Repo
|
||||
|
||||
@@ -188,7 +187,10 @@ local function do_refresh(repo)
|
||||
end
|
||||
end
|
||||
else
|
||||
log.warning("git status failed: %s", vim.trim(obj.stderr or ""))
|
||||
util.warning(
|
||||
"git status failed: %s",
|
||||
vim.trim(obj.stderr or "")
|
||||
)
|
||||
end
|
||||
local dirty = false
|
||||
for buf in pairs(repo.buffers) do
|
||||
@@ -336,7 +338,7 @@ function M.rev_parse(worktree, ref, short)
|
||||
table.insert(cmd, "--short")
|
||||
end
|
||||
table.insert(cmd, ref)
|
||||
local stdout = util.system_sync(cmd, { cwd = worktree, silent = true })
|
||||
local stdout = util.exec(cmd, { cwd = worktree, silent = true })
|
||||
local trimmed = stdout and vim.trim(stdout) or ""
|
||||
return trimmed ~= "" and trimmed or nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user