feat(git): highlight only fatal/error lines in failure dump

This commit is contained in:
2026-05-09 00:25:10 +02:00
parent 295803779a
commit 9bbbd1b1c8
2 changed files with 51 additions and 17 deletions
+23 -14
View File
@@ -550,7 +550,7 @@ t.test(
)
t.test(
"streaming :G fetch (no bang) on failure dumps output to :messages with ErrorMsg",
"streaming :G fetch (no bang) on failure highlights only fatal/error lines",
function()
make_repo({ a = "x" })
with_echo_stub(function(calls)
@@ -558,24 +558,33 @@ t.test(
t.wait_for(function()
return has_status(calls, "failed")
end, "failed progress notification", 5000)
local body = ""
---@type table?
local dump
for _, c in ipairs(calls) do
if
c.history == true
and c.chunks[1]
and c.chunks[1][2] == "ErrorMsg"
then
body = c.chunks[1][1]
if c.history == true then
dump = c.chunks
break
end
end
t.truthy(body ~= "", "expected ErrorMsg history dump")
local lower = string.lower(body)
t.truthy(dump, "expected history dump")
---@cast dump -nil
local fatal_chunks_red, plain_continuation = 0, false
for _, chunk in ipairs(dump) do
local text, hl = chunk[1], chunk[2]
if text:match("^fatal:") and hl == "ErrorMsg" then
fatal_chunks_red = fatal_chunks_red + 1
end
if text:match("Please make sure") and hl ~= "ErrorMsg" then
plain_continuation = true
end
end
t.truthy(
lower:match("repository")
or lower:match("remote")
or lower:match("fatal"),
"expected error mention in dump, got: " .. body
fatal_chunks_red >= 1,
"expected at least one fatal: line highlighted as ErrorMsg"
)
t.truthy(
plain_continuation,
"expected continuation line to be plain"
)
end)
end