refactor(git): centralise the git:// scheme behind util.uri / util.parse_uri

This commit is contained in:
2026-04-29 09:56:32 +02:00
parent 590651e9d8
commit 9d938b228b
4 changed files with 25 additions and 10 deletions
+16
View File
@@ -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