Skip to content

Commit 7229f0c

Browse files
shortcodes: fix version lag calculation for mixed CalVer/semver
Comparing a semver minor (e.g. 10 from v1.10.0) against a CalVer month (e.g. 3 from 26.03) produced a nonsensical negative lag. Now detects scheme per release: CalVer uses month-based lag, semver uses minor-based lag, and mixed schemes show a "legacy semver release" message instead of a meaningless number. Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Christian Heusel <christian@heusel.eu>
1 parent c538ffe commit 7229f0c

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

layouts/shortcodes/kf-version-notice.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,25 @@
4040
{{- $this_release_date := $this_release.publish_date | time.AsTime }}
4141
{{- $this_release_date_string := $this_release_date | time.Format ":date_long" }}
4242

43-
{{- $this_version_lag := sub $latest_release_minor $this_release_minor }}
44-
{{- $popup_content_prefix := printf "Kubeflow %s was initially released on <strong>%s</strong> and is <strong>%d</strong> minor versions behind the latest release." $version_full $this_release_date_string $this_version_lag }}
43+
{{- $latest_is_calver := not (strings.HasPrefix $latest_release.tag "v") }}
44+
{{- $this_is_calver := not (strings.HasPrefix $this_release.tag "v") }}
45+
{{- $this_version_lag := 0 }}
46+
{{- if and $latest_is_calver $this_is_calver }}
47+
{{- /* Both CalVer: compute lag in months */}}
48+
{{- $this_version_lag = sub (add (mul $latest_release_major 12) $latest_release_minor) (add (mul $this_release_major 12) $this_release_minor) }}
49+
{{- else if and (not $latest_is_calver) (not $this_is_calver) }}
50+
{{- /* Both semver: compare minor versions */}}
51+
{{- $this_version_lag = sub $latest_release_minor $this_release_minor }}
52+
{{- else }}
53+
{{- /* Mixed schemes: this is a legacy semver release, latest is CalVer */}}
54+
{{- $this_version_lag = -1 }}
55+
{{- end }}
56+
{{- $popup_content_prefix := "" }}
57+
{{- if lt $this_version_lag 0 }}
58+
{{- $popup_content_prefix = printf "Kubeflow %s was initially released on <strong>%s</strong> and is 1 version behind the latest release. This is a legacy semver release; the project has since moved to CalVer versioning." $version_full $this_release_date_string }}
59+
{{- else }}
60+
{{- $popup_content_prefix = printf "Kubeflow %s was initially released on <strong>%s</strong> and is <strong>%d</strong> minor versions behind the latest release." $version_full $this_release_date_string $this_version_lag }}
61+
{{- end }}
4562
{{- $popup_content_suffix := "Distributions are supported by their maintainers. Contact the provider for information on support and updates." }}
4663

4764
{{- $button_style := "" }}

0 commit comments

Comments
 (0)