fix(install): resolve release asset via Gitea API (download was always 404)
CI / cargo fmt --check (push) Successful in 29s
CI / cargo clippy (push) Successful in 40s
CI / cargo test (push) Successful in 46s
CI / editor keymaps (push) Successful in 1m40s

:NuwikiInstall always fell back to building from source because the
download URL used the GitHub-only shape
`/releases/latest/download/<asset>`, which this Gitea instance serves as
404. The release assets exist and are correctly named; only the URL was
wrong.

Resolve the asset's real download URL through the Gitea API instead: GET
`/api/v1/repos/.../releases/latest`, find the asset matching
`nuwiki-ls-<target>.tar.gz`, and download its `browser_download_url`
(`/releases/download/<tag>/<asset>`, which returns 200). Fixed in both
install paths — lua/nuwiki/install.lua (vim.json.decode) and
scripts/download_bin.vim (json_decode). Verified end to end: resolve →
download → extract → executable binary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 01:41:21 +00:00
parent 34a0607e7a
commit 3c1ed48a2f
2 changed files with 54 additions and 6 deletions
+26 -4
View File
@@ -66,6 +66,28 @@ local function build_from_source(dest)
return vim.fn.executable(dest) == 1
end
-- Gitea API base for this repo. Gitea has no GitHub-style
-- `/releases/latest/download/<asset>` shortcut, so resolve the asset's real
-- download URL (`browser_download_url`) through the API instead.
local REPO_API = 'https://code.gfran.co/api/v1/repos/gffranco/nuwiki'
local function latest_asset_url(asset_name)
local body = vim.fn.system({ 'curl', '-fsSL', REPO_API .. '/releases/latest' })
if vim.v.shell_error ~= 0 then
return nil
end
local ok, release = pcall(vim.json.decode, body)
if not ok or type(release) ~= 'table' or type(release.assets) ~= 'table' then
return nil
end
for _, a in ipairs(release.assets) do
if a.name == asset_name then
return a.browser_download_url
end
end
return nil
end
local function download_release(dest)
local target = target_triple()
if not target then
@@ -74,10 +96,10 @@ local function download_release(dest)
if vim.fn.executable('curl') ~= 1 or vim.fn.executable('tar') ~= 1 then
return false
end
local url = string.format(
'https://code.gfran.co/gffranco/nuwiki/releases/latest/download/nuwiki-ls-%s.tar.gz',
target
)
local url = latest_asset_url('nuwiki-ls-' .. target .. '.tar.gz')
if not url then
return false
end
local archive = vim.fn.tempname() .. '.tar.gz'
vim.fn.system({ 'curl', '-fsSL', '-o', archive, url })
if vim.v.shell_error ~= 0 then