mirror of
https://github.com/neovim/neovim.git
synced 2026-04-02 05:39:26 +00:00
fix(health): improve version check for nightly builds #38147
Problem: nightly builds were always compared against HEAD, causing false outdated warnings. Solution: fetch both HEAD and refs/tags/nightly, match local commit against HEAD first, fall back to nightly if no match. Fix #38141
This commit is contained in:
@@ -573,20 +573,37 @@ end
|
|||||||
local function check_head_hash(commit)
|
local function check_head_hash(commit)
|
||||||
local result = vim
|
local result = vim
|
||||||
.system(
|
.system(
|
||||||
{ 'git', 'ls-remote', 'https://github.com/neovim/neovim', 'HEAD' },
|
{ 'git', 'ls-remote', 'https://github.com/neovim/neovim', 'HEAD', 'refs/tags/nightly' },
|
||||||
{ text = true, timeout = 5000 }
|
{ text = true, timeout = 5000 }
|
||||||
)
|
)
|
||||||
:wait()
|
:wait()
|
||||||
if result.code ~= 0 or not result.stdout or result.stdout == '' then
|
if result.code ~= 0 or not result.stdout or result.stdout == '' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local upstream = assert(result.stdout:match('^(%x+)'))
|
|
||||||
if not vim.startswith(upstream, commit) then
|
local refs = {} ---@type table<string, string>
|
||||||
vim.health.warn(
|
for line in result.stdout:gmatch('[^\n]+') do
|
||||||
('Build is outdated. Local: %s, Latest: %s'):format(commit, upstream:sub(1, 12))
|
local sha, ref = line:match('^(%x+)%s+(%S+)$')
|
||||||
)
|
if sha and ref then
|
||||||
|
refs[ref] = sha
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local head_sha = assert(refs['HEAD'])
|
||||||
|
local nightly_sha = refs['refs/tags/nightly']
|
||||||
|
|
||||||
|
if vim.startswith(head_sha, commit) then
|
||||||
|
vim.health.ok('Up to date (HEAD)')
|
||||||
|
elseif nightly_sha and vim.startswith(nightly_sha, commit) then
|
||||||
|
vim.health.ok('Up to date (nightly)')
|
||||||
else
|
else
|
||||||
vim.health.ok(('Using latest HEAD: %s'):format(upstream:sub(1, 12)))
|
vim.health.warn(
|
||||||
|
('Build is outdated. Local: %s, HEAD: %s%s'):format(
|
||||||
|
commit,
|
||||||
|
head_sha:sub(1, 12),
|
||||||
|
nightly_sha and (', Nightly: ' .. nightly_sha:sub(1, 12)) or ''
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user