Fix: Don't error on untracked files with blame

Fixes #123
This commit is contained in:
Lewis Russell 2021-04-04 20:30:45 +01:00
parent 9113de1ed5
commit 36184e5a58
5 changed files with 26 additions and 2 deletions

View File

@ -749,7 +749,7 @@ end
local _current_line_blame = void_async(function()
local bufnr = current_buf()
local bcache = cache[bufnr]
if not bcache then
if not bcache or not bcache.object_name then
return
end

View File

@ -195,6 +195,10 @@ M.run_blame = a.wrap(function(
end,
on_exit = function()
local ret = {}
if #results == 0 then
callback({})
return
end
local header = vim.split(table.remove(results, 1), ' ')
ret.sha = header[1]
ret.abbrev_sha = string.sub(ret.sha, 1, 8)

View File

@ -749,7 +749,7 @@ end
local _current_line_blame = void_async(function()
local bufnr = current_buf()
local bcache = cache[bufnr]
if not bcache then
if not bcache or not bcache.object_name then
return
end

View File

@ -195,6 +195,10 @@ M.run_blame = a.wrap(function(
end,
on_exit = function()
local ret: {string:any} = {}
if #results == 0 then
callback({})
return
end
local header = vim.split(table.remove(results, 1), ' ')
ret.sha = header[1]
ret.abbrev_sha = string.sub(ret.sha as string, 1, 8)

View File

@ -436,6 +436,22 @@ describe('gitsigns', function()
end)
end)
describe('current line blame', function()
it('doesn\'t error on untracked files', function()
command("set updatetime=1")
init(true)
screen:detach()
screen:attach({ext_messages=true})
config.current_line_blame = true
exec_lua('gs.setup(...)', config)
sleep(20)
edit(newfile)
feed("iline<esc>")
command("write")
screen:expect{messages = { { content = { { "<" } }, kind = "" } } }
end)
end)
local function testsuite(advanced_features)
return function()
before_each(function()