This commit is contained in:
Nicolas Mailhot 2018-08-31 11:21:57 +02:00
parent 9278251531
commit 31fa384924

View File

@ -91,32 +91,29 @@ if (forgeurl ~= "") then
end end
else else
explicitset("forgeurl", forgeurl) explicitset("forgeurl", forgeurl)
if (commit == "") then
rpm.expand("%{error:All Gitlab URLs require commit value knowledge: you need to define %{commit}!\\nPlease vote on https://gitlab.com/gitlab-org/gitlab-ce/issues/38830\\n}")
end
safeset("archiveext", "tar.bz2") safeset("archiveext", "tar.bz2")
safeset("forgesetupargs", "-n %{archivename}") safeset("forgesetupargs", "-n %{archivename}")
if (commit ~= "") or (tag ~= "") then -- Packaging a moving branch is quite a bad idea, but since Gitlab
-- uses the same convention for tags and branches in archive downloads,
-- better do it explicitly than have packagers use the branch name in
-- %{tag}
local branch = rpm.expand("%{?branch}")
if (commit ~= "") or (tag ~= "") or (branch ~= "") then
safeset("scm", "git") safeset("scm", "git")
end end
local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)") local owner = string.match(forgeurl, "^[^:]+://[^/]+/([^/]+)")
local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)") local repo = string.match(forgeurl, "^[^:]+://[^/]+/[^/]+/([^/]+)")
local version = rpm.expand("%{?version}") local ref = ""
if (version ~= "") and (version ~= "0") and (tag == "") then if (commit ~= "") then ref = "%{?commit}"
-- GitLab does not have strong versionning semantics elseif (tag ~= "") then ref = "%{?tag}"
-- Some projects use "version" as release tag, others "v" + "version" elseif (branch ~= "") then ref = "%{?branch}"
-- Tag value needs to be explicitly declared before calling the macro else ref = "%{?version}"
-- in the second case
tag = version
safeset("tag", tag)
end end
if (tag ~= "") then if (rpm.expand(ref) == "") then
safeset("archivename", repo .. "-%{tag}-%{commit}") rpm.expand("%{error:You need to define %{version}, %{commit} or %{tag} before the macro invocation !\\n}")
safeset("archiveurl", "%{forgeurl}/repository/%{tag}/archive.%{archiveext}")
else
safeset("archivename", repo .. "-%{commit}")
safeset("archiveurl", "%{forgeurl}/repository/%{commit}/archive.%{archiveext}")
end end
safeset("archivename", repo .. "-" .. ref)
safeset("archiveurl", "%{forgeurl}/-/archive/" .. ref .. "/%{archivename}.%{archiveext}")
end end
end end
if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then if (string.match(forge, "^github[%.-]") or string.match(forge, "[%.-]github[%.]")) then