@@ 1,22 1,22 @@
local M = {}
---- @class RepoUrl.InfoOpts
+--- @class RepoUrl.UrlBuilderParams
--- @field base_url string
--- @field ref string
--- @field filepath string
--- @field line1 number?
--- @field line2 number?
---- @class RepoUrl.Info
---- @field blob_url fun(RepoUrl.InfoOpts): string
---- @field blame_url (fun(RepoUrl.InfoOpts): string)?
---- @field history_url (fun(RepoUrl.InfoOpts): string)?
---- @field raw_url (fun(RepoUrl.InfoOpts): string)?
---- @field tree_url (fun(RepoUrl.InfoOpts): string)?
+--- @class RepoUrl.UrlBuilder
+--- @field blob_url fun(RepoUrl.UrlBuilderParams): string
+--- @field blame_url (fun(RepoUrl.UrlBuilderParams): string)?
+--- @field history_url (fun(RepoUrl.UrlBuilderParams): string)?
+--- @field raw_url (fun(RepoUrl.UrlBuilderParams): string)?
+--- @field tree_url (fun(RepoUrl.UrlBuilderParams): string)?
local fallback_gocache_dir = nil
---- @type fun(RepoUrl.InfoOpts, string, string?): string
+--- @type fun(RepoUrl.UrlBuilderParams, string, string?): string
local pos_to_path = function(opts, format1, format2)
if opts == nil or opts.line1 == nil then
return ''
@@ 27,7 27,7 @@ local pos_to_path = function(opts, format1, format2)
end
end
---- @type table<string, RepoUrl.Info>
+--- @type table<string, RepoUrl.UrlBuilder>
M.urls = {
github = {
blob_url = function(opts)
@@ 138,7 138,7 @@ M.urls = {
--- @class RepoUrl.Config
--- @field preferred_remotes string[]?
---- @field urls_by_hostname table<string, RepoUrl.Info>?
+--- @field urls_by_hostname table<string, RepoUrl.UrlBuilder>?
--- @type RepoUrl.Config
local config = {
@@ 154,7 154,7 @@ local config = {
},
}
---- @type fun(string): RepoUrl.Info?
+--- @type fun(string): RepoUrl.UrlBuilder?
local pick_urls = function(hostname)
return config.urls_by_hostname[hostname]
end
@@ 426,9 426,6 @@ M.get_blame_url = function()
if urls == nil then
error(string.format("hostname '%s' not matching any URLs", res.hostname))
end
- if urls.blame_url == nil then
- error("blame_url not defined for '%s'", res.hostname)
- end
if not urls.blame_url then
error(string.format("blame_url() not defined for hostname '%s'", res.hostname))
end
@@ 457,9 454,6 @@ M.get_history_url = function()
if urls == nil then
error(string.format("hostname '%s' not matching any URLs", res.hostname))
end
- if urls.history_url == nil then
- error("history_url not defined for '%s'", res.hostname)
- end
if not urls.history_url then
error(string.format("history_url() not defined for hostname '%s'", res.hostname))
end
@@ 488,9 482,6 @@ M.get_raw_url = function()
if urls == nil then
error(string.format("hostname '%s' not matching any URLs", res.hostname))
end
- if urls.raw_url == nil then
- error("raw_url not defined for '%s'", res.hostname)
- end
if not urls.raw_url then
error(string.format("raw_url() not defined for hostname '%s'", res.hostname))
end