Problem: forge auth/warning logic was scattered through `fetch_metadata` — per-API-call auth status checks, `_warned` flags, and `warn_missing_cli` conditionals on every fetch. Solution: replace `_warned` with `_auth` (cached per session), add `is_configured()` to skip unconfigured forges entirely, extract `check_auth()` for one-time auth verification, and strip `fetch_metadata` to a pure API caller returning `ForgeFetchError`. Gate `refresh` and new `validate_refs` with both checks. Rename `gitea_backend` to `gitea_forge`.
76 lines
2.3 KiB
Lua
76 lines
2.3 KiB
Lua
local M = {}
|
|
|
|
---@return nil
|
|
function M.check()
|
|
vim.health.start('pending.nvim')
|
|
|
|
local ok, config = pcall(require, 'pending.config')
|
|
if not ok then
|
|
vim.health.error('Failed to load pending.config')
|
|
return
|
|
end
|
|
|
|
config.get()
|
|
vim.health.ok('Config loaded')
|
|
|
|
local store_ok, store = pcall(require, 'pending.store')
|
|
if not store_ok then
|
|
vim.health.error('Failed to load pending.store')
|
|
return
|
|
end
|
|
|
|
local resolved_path = store.resolve_path()
|
|
vim.health.info('Store path: ' .. resolved_path)
|
|
|
|
if vim.fn.filereadable(resolved_path) == 1 then
|
|
local s = store.new(resolved_path)
|
|
local load_ok, err = pcall(function()
|
|
s:load()
|
|
end)
|
|
if load_ok then
|
|
local tasks = s:tasks()
|
|
vim.health.ok('Data file loaded: ' .. #tasks .. ' tasks')
|
|
local recur = require('pending.recur')
|
|
local invalid_count = 0
|
|
for _, task in ipairs(tasks) do
|
|
if task.recur and not recur.validate(task.recur) then
|
|
invalid_count = invalid_count + 1
|
|
vim.health.warn('Task ' .. task.id .. ' has invalid recurrence spec: ' .. task.recur)
|
|
end
|
|
end
|
|
if invalid_count == 0 then
|
|
vim.health.ok('All recurrence specs are valid')
|
|
end
|
|
else
|
|
vim.health.error('Failed to load data file: ' .. tostring(err))
|
|
end
|
|
end
|
|
|
|
vim.health.start('pending.nvim: forge')
|
|
local forge = require('pending.forge')
|
|
for _, backend in ipairs(forge.backends()) do
|
|
if not forge.is_configured(backend.name) then
|
|
vim.health.info(('%s: not configured (skipped)'):format(backend.name))
|
|
elseif vim.fn.executable(backend.cli) == 1 then
|
|
vim.health.ok(('%s found'):format(backend.cli))
|
|
else
|
|
vim.health.warn(('%s not found — run `%s`'):format(backend.cli, backend.auth_cmd))
|
|
end
|
|
end
|
|
|
|
local sync_paths = vim.fn.globpath(vim.o.runtimepath, 'lua/pending/sync/*.lua', false, true)
|
|
if #sync_paths == 0 then
|
|
vim.health.info('No sync backends found')
|
|
else
|
|
for _, path in ipairs(sync_paths) do
|
|
local name = vim.fn.fnamemodify(path, ':t:r')
|
|
local bok, backend = pcall(require, 'pending.sync.' .. name)
|
|
if bok and backend.name and type(backend.health) == 'function' then
|
|
vim.health.start('pending.nvim: sync/' .. name)
|
|
backend.health()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return M
|