refactor(git): centralise the git:// scheme behind util.uri / util.parse_uri
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
local M = {}
|
||||
|
||||
local URI_PREFIX = "git://"
|
||||
|
||||
---@param revspec string
|
||||
---@return string
|
||||
function M.uri(revspec)
|
||||
return URI_PREFIX .. revspec
|
||||
end
|
||||
|
||||
---Extract the revspec from a `git://<revspec>` buffer name. Returns
|
||||
---nil if the name doesn't carry the scheme.
|
||||
---@param name string
|
||||
---@return string?
|
||||
function M.parse_uri(name)
|
||||
return name:match("^" .. URI_PREFIX .. "(.+)$")
|
||||
end
|
||||
|
||||
---@class ow.Git.ParsedRevspec
|
||||
---@field stage 0|1|2|3? index stage when the revspec is `:<path>` / `:0:<path>` / `:N:<path>`; nil otherwise
|
||||
---@field path string? path component when the revspec carries one; nil for bare object refs
|
||||
|
||||
Reference in New Issue
Block a user