Merge pull request 'feat(updates): use full Joomla channel names in update feeds' (#264) from feat/inline-visibility-settings into dev
Universal: Auto Version Bump / Version Bump (push) Has been skipped
Universal: Auto Version Bump / Version Bump (push) Has been skipped
This commit was merged in pull request #264.
This commit is contained in:
@@ -56,6 +56,10 @@ func validateUpdateKey(ctx *context.Context) (allowedChannels []string, ok bool)
|
||||
channels = parsed
|
||||
}
|
||||
}
|
||||
// Normalize shorthand names to full Joomla convention.
|
||||
for i := range channels {
|
||||
channels[i] = updateserver.NormalizeChannel(channels[i])
|
||||
}
|
||||
return channels, true
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func GenerateDolibarrJSON(ctx context.Context, repo *repo_model.Repository) (*Do
|
||||
}
|
||||
}
|
||||
|
||||
for _, ch := range []string{"stable", "rc", "beta", "alpha", "dev"} {
|
||||
for _, ch := range AllChannels {
|
||||
rel, ok := bestByChannel[ch]
|
||||
if !ok {
|
||||
continue
|
||||
|
||||
@@ -64,22 +64,54 @@ type xmlTargetPlat struct {
|
||||
Version string `xml:"version,attr"`
|
||||
}
|
||||
|
||||
// channelFromTag maps a release tag name to a Joomla update channel.
|
||||
// Joomla update stream names (full convention).
|
||||
const (
|
||||
ChannelStable = "stable"
|
||||
ChannelReleaseCandidate = "release-candidate"
|
||||
ChannelBeta = "beta"
|
||||
ChannelAlpha = "alpha"
|
||||
ChannelDevelopment = "development"
|
||||
)
|
||||
|
||||
// AllChannels in display order (most stable first).
|
||||
var AllChannels = []string{ChannelStable, ChannelReleaseCandidate, ChannelBeta, ChannelAlpha, ChannelDevelopment}
|
||||
|
||||
// channelFromTag maps a release tag name to a Joomla update channel.
|
||||
func channelFromTag(tagName string, isPrerelease bool) string {
|
||||
lower := strings.ToLower(tagName)
|
||||
switch {
|
||||
case strings.Contains(lower, "-dev") || strings.Contains(lower, "development"):
|
||||
return "dev"
|
||||
case strings.Contains(lower, "-alpha") || strings.Contains(lower, "alpha"):
|
||||
return "alpha"
|
||||
case strings.Contains(lower, "-beta") || strings.Contains(lower, "beta"):
|
||||
return "beta"
|
||||
return ChannelDevelopment
|
||||
case strings.Contains(lower, "-alpha"):
|
||||
return ChannelAlpha
|
||||
case strings.Contains(lower, "-beta"):
|
||||
return ChannelBeta
|
||||
case strings.Contains(lower, "-rc") || strings.Contains(lower, "release-candidate"):
|
||||
return "rc"
|
||||
return ChannelReleaseCandidate
|
||||
case isPrerelease:
|
||||
return "rc"
|
||||
return ChannelReleaseCandidate
|
||||
default:
|
||||
return "stable"
|
||||
return ChannelStable
|
||||
}
|
||||
}
|
||||
|
||||
// NormalizeChannel maps shorthand channel names to the full Joomla convention.
|
||||
// Accepts both "rc" and "release-candidate", "dev" and "development", etc.
|
||||
func NormalizeChannel(ch string) string {
|
||||
switch strings.ToLower(ch) {
|
||||
case "rc", "release-candidate":
|
||||
return ChannelReleaseCandidate
|
||||
case "dev", "development":
|
||||
return ChannelDevelopment
|
||||
case "alpha":
|
||||
return ChannelAlpha
|
||||
case "beta":
|
||||
return ChannelBeta
|
||||
case "stable":
|
||||
return ChannelStable
|
||||
default:
|
||||
return ch
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,15 +156,16 @@ func GenerateJoomlaXML(ctx context.Context, repo *repo_model.Repository, allowed
|
||||
}
|
||||
|
||||
// Build allowed channel set for filtering.
|
||||
// Normalize shorthand names so both "rc" and "release-candidate" work.
|
||||
channelAllowed := make(map[string]bool)
|
||||
if len(allowedChannels) > 0 {
|
||||
for _, c := range allowedChannels {
|
||||
channelAllowed[strings.ToLower(c)] = true
|
||||
channelAllowed[NormalizeChannel(c)] = true
|
||||
}
|
||||
}
|
||||
|
||||
var updates xmlUpdates
|
||||
for _, ch := range []string{"stable", "rc", "beta", "alpha", "dev"} {
|
||||
for _, ch := range AllChannels {
|
||||
// Skip channels not in the allowed set (when filtering is active).
|
||||
if len(channelAllowed) > 0 && !channelAllowed[ch] {
|
||||
continue
|
||||
@@ -223,13 +256,13 @@ func extractVersion(tagName string) string {
|
||||
// channelSuffix returns the version suffix for a channel.
|
||||
func channelSuffix(channel string) string {
|
||||
switch channel {
|
||||
case "dev":
|
||||
case ChannelDevelopment:
|
||||
return "-dev"
|
||||
case "alpha":
|
||||
case ChannelAlpha:
|
||||
return "-alpha"
|
||||
case "beta":
|
||||
case ChannelBeta:
|
||||
return "-beta"
|
||||
case "rc":
|
||||
case ChannelReleaseCandidate:
|
||||
return "-rc"
|
||||
default:
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user