fix(blame): better error message when blame fails

Closes #776
This commit is contained in:
Lewis Russell 2023-09-22 16:28:45 +01:00
parent e2b8e61ce0
commit f0e9f5dd32
2 changed files with 25 additions and 4 deletions

View file

@ -17,6 +17,7 @@ local dprint = require('gitsigns.debug.log').dprint
local dprintf = require('gitsigns.debug.log').dprintf
local eprint = require('gitsigns.debug.log').eprint
local err = require('gitsigns.message').error
local error_once = require('gitsigns.message').error_once
local M = {}
@ -636,7 +637,12 @@ function Obj:run_blame(lines, lnum, ignore_whitespace)
vim.list_extend(args, { '--ignore-revs-file', ignore_file })
end
local results = self:command(args, { writer = lines })
local results, stderr = self:command(args, { writer = lines, suppress_stderr = true })
if stderr then
error_once('Error running git-blame: '.. stderr)
return
end
if #results == 0 then
return
end

View file

@ -1,13 +1,28 @@
local M = {}
-- local eprint = require('gitsigns.debug.log').eprint
--- @type fun(fmt: string, ...: string)
M.warn = vim.schedule_wrap(function(s, ...)
vim.notify(s:format(...), vim.log.levels.WARN, { title = 'gitsigns' })
end)
--- @type fun(fmt: string, ...: string)
M.error = vim.schedule_wrap(function(s, ...)
vim.notify(s:format(...), vim.log.levels.ERROR, { title = 'gitsigns' })
end)
M.error = function(s, ...)
local msg = s:format(...) --- @type string
-- eprint(msg)
vim.schedule(function()
vim.notify(msg, vim.log.levels.ERROR, { title = 'gitsigns' })
end)
end
--- @type fun(fmt: string, ...: string)
M.error_once = function(s, ...)
local msg = s:format(...) --- @type string
-- eprint(msg)
vim.schedule(function()
vim.notify_once(msg, vim.log.levels.ERROR, { title = 'gitsigns' })
end)
end
return M