feat(blame): support every file-shaped git:// URI
This commit is contained in:
+14
-2
@@ -192,14 +192,26 @@ local function resolve_source(buf)
|
||||
local name = vim.api.nvim_buf_get_name(buf)
|
||||
if util.is_uri(name) then
|
||||
local rev = object.parse_uri(name)
|
||||
if not rev or not rev.base or not rev.path then
|
||||
if not rev then
|
||||
return nil
|
||||
end
|
||||
local r = repo.find(buf)
|
||||
if not r then
|
||||
return nil
|
||||
end
|
||||
return { repo = r, rel = rev.path, revision = rev.base }
|
||||
local rel = rev.path
|
||||
if not rel then
|
||||
local state = r:state(buf)
|
||||
rel = state and state.blob_path or nil
|
||||
if not rel then
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local revision = nil
|
||||
if rev.path and rev.base and rev.stage == nil then
|
||||
revision = rev.base
|
||||
end
|
||||
return { repo = r, rel = rel, revision = revision }
|
||||
end
|
||||
if not repo.is_worktree_buf(buf) then
|
||||
return nil
|
||||
|
||||
@@ -19,6 +19,7 @@ end
|
||||
---@field immutable boolean?
|
||||
---@field index_writer boolean?
|
||||
---@field index_mode string?
|
||||
---@field blob_path string?
|
||||
|
||||
---@alias ow.Git.Repo.Event
|
||||
---| "change"
|
||||
|
||||
@@ -321,6 +321,10 @@ local function side_buf(r, blob, path)
|
||||
if full then
|
||||
local buf = M.buf_for(r, Revision.new({ base = full }))
|
||||
set_ft_from_path(buf, path)
|
||||
local state = r:state(buf)
|
||||
if state then
|
||||
state.blob_path = path
|
||||
end
|
||||
return buf
|
||||
end
|
||||
local p = vim.fs.joinpath(r.worktree, path)
|
||||
|
||||
Reference in New Issue
Block a user