online 0 ˆÁÀ ƒh¹¿¾0 #ˆl–äY>” ªn-jm@;p-Üi•1hßÁ „ n_À¿=-- Lua code used by macros.forge and derivatives -- Computes the suffix of a version string, removing vprefix if it matches -- For example with vprefix 1.2.3: 1.2.3.rc2 → .rc2 but 1.2.30 → 1.2.30 not 0 local function getversionsuffix(vstring,vprefix) if (string.sub(vstring, 1, #vprefix) == vprefix) and (not string.match(string.sub(vstring, #vprefix + 1), "^%.?%d")) then return string.sub(vstring, #vprefix + 1) else return vstring end end -- Check if an identified url is sane local function checkforgeurl(url, id, silent) local checkedurl = nil local checkedid = nil local urlpatterns = { gitlab = { pattern = 'https://[^/]+/[^/]+/[^/#?]+', description = 'https://(…[-.])gitlab[-.]…/owner/repo'}, pagure = { pattern = 'https://[^/]+/[^/#?]+', description = 'https://pagure.io/repo'}, pagure_ns = { pattern = 'https://[^/]+/[^/]+/[^/#?]+', description = 'https://pagure.io/namespace/repo'}, pagure_fork = { pattern = 'https://[^/]+/fork/[^/]+/[^/#?]+', description = 'https://pagure.io/fork/owner/repo'}, pagure_ns_fork = { pattern = 'https://[^/]+/fork/[^/]+/[^/]+/[^/#?]+', description = 'https://pagure.io/fork/owner/namespace/repo'}, ["gitea.com"] = { pattern = 'https://[^/]+/[^/]+/[^/#?]+', description = 'https://gitea.com/owner/repo'}, github = { pattern = 'https://[^/]+/[^/]+/[^/#?]+', description = 'https://(…[-.])github[-.]…/owner/repo'}, ["code.googlesource.com"] = { pattern = 'https://code.googlesource.com/[^#?]*[^/#?]+', description = 'https://code.googlesource.com/…/repo'}, ["bitbucket.org"] = { pattern = 'https://[^/]+/[^/]+/[^/#?]+', description = 'https://bitbucket.org/owner/repo'}} if (urlpatterns[id] ~= nil) then checkedurl = string.match(url,urlpatterns[id]["pattern"]) if (checkedurl == nil) then if not silent then rpm.expand("%{error:" .. id .. " URLs must match " .. urlpatterns[id]["description"] .. " !}") end else checkedid = id end end return checkedurl, checkedid end -- Check if an url matches a known forge local function idforge(url, silent) local forgeurl = nil local forge = nil if (url ~= "") then forge = string.match(url, "^[^:]+://([^/]+)/") if (forge == nil) then if not silent then rpm.expand("%{error:URLs must include a protocol such as https:// and a path starting with / !}") end else if (forge == "pagure.io") then if string.match(url, "[^:]+://pagure.io/fork/[^/]+/[^/]+/[^/]+") then forge = "pagure_ns_fork" elseif string.match(url, "[^:]+://pagure.io/fork/[^/]+/[^/]+") then forge = "pagure_fork" elseif string.match(url, "[^:]+://pagure.io/[^/]+/[^/]+") then forge = "pagure_ns" elseif string.match(url, "[^:]+://pagure.io/[^/]+") then forge = "pagure" end elseif (string.match(forge, "^gitlab[%.-]") or string.match(forge, "[%.-]gitlab[%.]")) then forge = "gitlab" elseif (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then forge = "github" end forgeurl, forge = checkforgeurl(url, forge, silent) end end return forgeurl, forge end -- The forgemeta macro main processing function -- See the documentation in the macros.forge file for argument description -- Also called directly by gometa local function meta(suffix, verbose, informative, silent) local fedora = require "fedora.common" local ismain = (suffix == "") or (suffix == "0") if ismain then fedora.zalias({"forgeurl", "forgesource", "forgesetupargs", "archivename", "archiveext", "archiveurl", "topdir", "extractdir", "repo", "owner", "namespace", "scm", "tag", "commit", "shortcommit", "branch", "version",