refactor(git): keep routine success output out of :messages
This commit is contained in:
+1
-1
@@ -238,7 +238,7 @@ local function run_to_messages(r, args)
|
||||
)
|
||||
end
|
||||
if #chunks > 0 then
|
||||
vim.api.nvim_echo(chunks, true, {})
|
||||
vim.api.nvim_echo(chunks, failed or err ~= "", {})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ function M.commit(opts)
|
||||
end
|
||||
local out = vim.trim(result.stdout or "")
|
||||
if out ~= "" then
|
||||
util.info("%s", out)
|
||||
vim.api.nvim_echo({ { out } }, false, {})
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -509,6 +509,41 @@ local function has_status(calls, status)
|
||||
return false
|
||||
end
|
||||
|
||||
---@param calls { history: boolean }[]
|
||||
---@return boolean
|
||||
local function any_history(calls)
|
||||
for _, c in ipairs(calls) do
|
||||
if c.history then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
t.test("quiet :G success does not add to :messages history", function()
|
||||
make_repo({ a = "x" })
|
||||
with_echo_stub(function(calls)
|
||||
cmd.run({ "config", "user.email" })
|
||||
t.falsy(any_history(calls), "success path must not write history")
|
||||
end)
|
||||
end)
|
||||
|
||||
t.test("quiet :G silent failure adds 'git exited N' to history", function()
|
||||
make_repo({ a = "x" })
|
||||
with_echo_stub(function(calls)
|
||||
cmd.run({ "config", "--get", "nonexistent.foo.bar" })
|
||||
t.truthy(any_history(calls), "failure path must write history")
|
||||
end)
|
||||
end)
|
||||
|
||||
t.test("quiet :G stderr failure adds error to history", function()
|
||||
make_repo({ a = "x" })
|
||||
with_echo_stub(function(calls)
|
||||
cmd.run({ "branch", "-d", "nonexistent-branch" })
|
||||
t.truthy(any_history(calls), "failure path must write history")
|
||||
end)
|
||||
end)
|
||||
|
||||
t.test("streaming :G fetch (no bang) does not open a window", function()
|
||||
make_repo({ a = "x" })
|
||||
with_echo_stub(function(calls)
|
||||
|
||||
Reference in New Issue
Block a user