mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2024-09-16 14:34:09 +02:00
fix: get the repo version of the username
This commit is contained in:
parent
d44a7948ff
commit
2e5719c79a
3 changed files with 14 additions and 15 deletions
|
@ -48,6 +48,9 @@ M.Obj = Obj
|
|||
--- @field abbrev_head string
|
||||
|
||||
--- @class Gitsigns.Repo : Gitsigns.RepoInfo
|
||||
---
|
||||
--- Username configured for the repo.
|
||||
--- Needed for to determine "You" in current line blame.
|
||||
--- @field username string
|
||||
local Repo = {}
|
||||
M.Repo = Repo
|
||||
|
@ -328,7 +331,6 @@ end
|
|||
function Repo.new(dir, gitdir, toplevel)
|
||||
local self = setmetatable({}, { __index = Repo })
|
||||
|
||||
self.username = git_command({ 'config', 'user.name' }, { ignore_error = true })[1]
|
||||
local info = M.get_repo_info(dir, nil, gitdir, toplevel)
|
||||
for k, v in
|
||||
pairs(info --[[@as table<string,any>]])
|
||||
|
@ -337,6 +339,8 @@ function Repo.new(dir, gitdir, toplevel)
|
|||
self[k] = v
|
||||
end
|
||||
|
||||
self.username = self:command({ 'config', 'user.name' }, { ignore_error = true })[1]
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
|
|
@ -46,10 +46,10 @@ describe('gitdir_watcher', function()
|
|||
|
||||
match_debug_messages({
|
||||
'attach(1): Attaching (trigger=BufReadPost)',
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* config user.name'),
|
||||
np('run_job: git .* ls%-files .* ' .. vim.pesc(test_file)),
|
||||
n('watch_gitdir(1): Watching git dir'),
|
||||
np('run_job: git .* show .*'),
|
||||
|
|
|
@ -125,10 +125,10 @@ describe('gitsigns (with screen)', function()
|
|||
|
||||
match_debug_messages({
|
||||
'attach(1): Attaching (trigger=BufReadPost)',
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* config user.name'),
|
||||
n('new: Not in git repo'),
|
||||
n('attach(1): Empty git obj'),
|
||||
})
|
||||
|
@ -139,10 +139,10 @@ describe('gitsigns (with screen)', function()
|
|||
|
||||
match_debug_messages({
|
||||
n('attach(1): Attaching (trigger=BufWritePost)'),
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* config user.name'),
|
||||
n('new: Not in git repo'),
|
||||
n('attach(1): Empty git obj'),
|
||||
})
|
||||
|
@ -192,10 +192,10 @@ describe('gitsigns (with screen)', function()
|
|||
|
||||
match_debug_messages({
|
||||
'attach(1): Attaching (trigger=BufReadPost)',
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* config user.name'),
|
||||
np('run_job: git .* ls%-files .*/dummy_ignored.txt'),
|
||||
n('attach(1): Cannot resolve file in repo'),
|
||||
})
|
||||
|
@ -208,10 +208,10 @@ describe('gitsigns (with screen)', function()
|
|||
|
||||
match_debug_messages({
|
||||
'attach(1): Attaching (trigger=BufNewFile)',
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* ls%-files %-%-stage %-%-others %-%-exclude%-standard %-%-eol '
|
||||
.. vim.pesc(newfile)
|
||||
|
@ -288,14 +288,9 @@ describe('gitsigns (with screen)', function()
|
|||
feed('gg')
|
||||
check({ signs = {} })
|
||||
|
||||
-- Wait until the virtual blame line appears
|
||||
-- screen:sleep(500)
|
||||
-- print(vim.inspect(exec_lua[[return require'gitsigns.cache'.cache[vim.api.nvim_get_current_buf()].compare_text]]))
|
||||
-- print(vim.inspect(exec_lua[[return require'gitsigns.util'.buf_lines(vim.api.nvim_get_current_buf())]]))
|
||||
|
||||
screen:expect({
|
||||
grid = [[
|
||||
^{MATCH:This {6: tester, %d seco}}|
|
||||
^{MATCH:This {6: You, %d second.}}|
|
||||
is |
|
||||
a |
|
||||
windows |
|
||||
|
@ -349,11 +344,11 @@ describe('gitsigns (with screen)', function()
|
|||
edit(test_file)
|
||||
match_debug_messages({
|
||||
'attach(1): Attaching (trigger=BufReadPost)',
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* rev%-parse %-%-short HEAD'),
|
||||
np('run_job: git .* config user.name'),
|
||||
np('run_job: git .* %-%-git%-dir .* %-%-stage %-%-others %-%-exclude%-standard %-%-eol.*'),
|
||||
n('attach(1): User on_attach() returned false'),
|
||||
})
|
||||
|
@ -466,10 +461,10 @@ describe('gitsigns (with screen)', function()
|
|||
edit(newfile)
|
||||
match_debug_messages({
|
||||
'attach(1): Attaching (trigger=BufNewFile)',
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* config user.name'),
|
||||
np('run_job: git .* ls%-files .*'),
|
||||
n('attach(1): Not a file'),
|
||||
})
|
||||
|
@ -477,10 +472,10 @@ describe('gitsigns (with screen)', function()
|
|||
|
||||
local messages = {
|
||||
'attach(1): Attaching (trigger=BufWritePost)',
|
||||
np('run_job: git .* config user.name'),
|
||||
np(
|
||||
'run_job: git .* rev%-parse %-%-show%-toplevel %-%-absolute%-git%-dir %-%-abbrev%-ref HEAD'
|
||||
),
|
||||
np('run_job: git .* config user.name'),
|
||||
np('run_job: git .* ls%-files .*'),
|
||||
n('watch_gitdir(1): Watching git dir'),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue