fix: update server feed generation bugs (#601)
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 2s
Universal: Build & Release / Build & Release Pipeline (pull_request) Has been skipped
Branch Policy Check / Verify merge target (pull_request) Failing after 2s
Universal: PR Check / Branch Policy (pull_request) Failing after 3s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Generic: Repo Health / Access control (pull_request) Successful in 3s
Universal: Build & Release / Promote to RC (pull_request) Failing after 14s
Universal: PR Check / Validate PR (pull_request) Failing after 14s
Generic: Project CI / Lint & Validate (pull_request) Successful in 51s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 59s
PR RC Release / Build RC Release (pull_request) Failing after 1m27s
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
Generic: Project CI / Tests (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report Issues (pull_request) Has been cancelled

- Change default targetplatform from (5|6)\.* to 6\..* for Joomla 6 compat
- Use FullElementName() to auto-construct element from PackageType + Name
- Change <client> from string (site/administrator) to numeric (0/1)
- Preserve pre-release version suffix number (e.g. -rc2 not just -rc)

Co-Authored-By: Moko Consulting <hello@mokoconsulting.tech>
This commit is contained in:
Jonathan Miller
2026-06-11 16:28:00 -05:00
parent 24a33fdd4d
commit 7dfb11070d
+27 -17
View File
@@ -183,7 +183,7 @@ func resolveExtensionMetadata(ctx context.Context, repo *repo_model.Repository,
Element: strings.ToLower(repo.Name),
DisplayName: fmt.Sprintf("%s - %s", repo.Owner.Name, repo.Name),
ExtType: "component",
TargetVersion: "(5|6)\\..*",
TargetVersion: "6\\..*",
}
// Manifest is the source of truth for extension metadata.
@@ -192,8 +192,8 @@ func resolveExtensionMetadata(ctx context.Context, repo *repo_model.Repository,
log.Error("resolveExtensionMetadata: GetRepoManifest for repo %d: %v", repo.ID, err)
}
if manifest != nil {
if manifest.ElementName != "" {
m.Element = manifest.ElementName
if elem := manifest.FullElementName(); elem != "" {
m.Element = elem
}
if manifest.PackageType != "" {
m.ExtType = manifest.PackageType
@@ -361,11 +361,13 @@ func GenerateJoomlaXML(ctx context.Context, repo *repo_model.Repository, require
if version == "" {
version = rel.TagName
}
// Append channel suffix only if the version doesn't already
// contain one (e.g. "1.2.3-rc2" already has "-rc").
suffix := stream.Suffix
if suffix == "" {
suffix = channelSuffix(ch) // fallback for Joomla defaults
suffix = channelSuffix(ch)
}
if suffix != "" {
if suffix != "" && !versionHasChannelSuffix(version) {
version = version + suffix
}
@@ -380,13 +382,12 @@ func GenerateJoomlaXML(ctx context.Context, repo *repo_model.Repository, require
infoURL = meta.SupportURL
}
// Joomla <client> element: admin-side extensions use "administrator",
// site-side extensions use "site". Packages, components, libraries,
// and files are admin-side by default.
client := "site"
// Joomla <client> element: 0 = site, 1 = administrator.
// Packages, components, libraries, and files are admin-side.
client := "0"
switch extType {
case "package", "component", "library", "file":
client = "administrator"
client = "1"
}
u := xmlUpdate{
@@ -447,13 +448,10 @@ func extractVersion(s string) string {
v = strings.TrimPrefix(v, "v")
v = strings.TrimPrefix(v, "release-")
v = strings.TrimPrefix(v, "release/")
// Strip channel suffixes.
for _, suffix := range []string{"-dev", "-alpha", "-beta", "-rc", "-development", "-release-candidate"} {
if idx := strings.Index(strings.ToLower(v), suffix); idx > 0 {
v = v[:idx]
break
}
}
// Do not strip channel suffixes (e.g. -rc2, -beta1) here.
// The caller appends stream suffixes only when the version
// doesn't already contain one, preserving the original
// pre-release number for correct Joomla version comparison.
// If result looks like a version (starts with digit), use it.
if len(v) > 0 && v[0] >= '0' && v[0] <= '9' {
return strings.TrimSpace(v)
@@ -467,6 +465,18 @@ func extractVersion(s string) string {
return ""
}
// versionHasChannelSuffix checks if a version string already contains a
// pre-release channel suffix (e.g. "-rc", "-beta1", "-dev").
func versionHasChannelSuffix(version string) bool {
lower := strings.ToLower(version)
for _, s := range []string{"-dev", "-alpha", "-beta", "-rc"} {
if strings.Contains(lower, s) {
return true
}
}
return false
}
// channelSuffix returns the version suffix for a channel.
func channelSuffix(channel string) string {
switch channel {