mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2024-09-16 14:34:09 +02:00
parent
6f8dbdbd41
commit
f074844b60
2 changed files with 18 additions and 6 deletions
|
@ -41,13 +41,25 @@ end
|
|||
--- @return string buffer
|
||||
--- @return string? commit
|
||||
local function parse_gitsigns_uri(name)
|
||||
-- TODO(lewis6991): Support submodules
|
||||
--- @type any, any, string?, string?, string
|
||||
local _, _, root_path, commit, rel_path = name:find([[^gitsigns://(.*)/%.git/(.*):(.*)]])
|
||||
local _proto, head, tail = unpack(vim.split(name, '//'))
|
||||
|
||||
--- @type any, any, string?, string?
|
||||
local _, _, root_path, sub_path = head:find([[(.*)/%.git(.*)]])
|
||||
|
||||
--- @type any, any, string?, string?
|
||||
local _, _, commit, rel_path = tail:find([[(.*):(.*)]])
|
||||
|
||||
commit = util.norm_base(commit)
|
||||
|
||||
if root_path then
|
||||
name = root_path .. '/' .. rel_path
|
||||
if sub_path then
|
||||
sub_path = sub_path:gsub('^/modules/', '')
|
||||
name = string.format('%s/%s/%s', root_path, sub_path, rel_path)
|
||||
else
|
||||
name = string.format('%s/%s', root_path, rel_path)
|
||||
end
|
||||
end
|
||||
|
||||
return name, commit
|
||||
end
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ local CacheEntry = M.CacheEntry
|
|||
function CacheEntry:get_rev_bufname(rev, nofile)
|
||||
rev = rev or self.git_obj.revision or ':0'
|
||||
if nofile then
|
||||
return string.format('gitsigns://%s/%s', self.git_obj.repo.gitdir, rev)
|
||||
return string.format('gitsigns://%s//%s', self.git_obj.repo.gitdir, rev)
|
||||
end
|
||||
return string.format('gitsigns://%s/%s:%s', self.git_obj.repo.gitdir, rev, self.git_obj.relpath)
|
||||
return string.format('gitsigns://%s//%s:%s', self.git_obj.repo.gitdir, rev, self.git_obj.relpath)
|
||||
end
|
||||
|
||||
--- Invalidate any state dependent on the buffer content.
|
||||
|
|
Loading…
Reference in a new issue