Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions testdata/kodo-e2e/formulas/pnggroup/libpng/Libpng_cmp.gox
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compareVer (a, b) => {
// Prefer released versions over libpng's non-semver beta tags. For example,
// v1.6.58 is valid semver while v1.7.0beta89 is not.
return semver.compare(a.Version, b.Version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment overstates the behavior + naming inconsistent with sibling comparators.

  1. The comment says this "prefer[s] released versions over libpng's non-semver beta tags," but the body just delegates to semver.Compare(a.Version, b.Version) — there is no beta-handling logic here. The "preference" is an incidental side effect of golang.org/x/mod/semver: an invalid semver string canonicalizes to "" and sorts below any valid version. Note v1.7.0beta89 is invalid semver (a prerelease needs a hyphen, v1.7.0-beta89), so all such non-canonical tags collapse to a single "equal, lowest" bucket — they can't be ordered relative to each other, and a newer v1.7.0beta89 sorts below an older released v1.6.58. Consider rewording to describe the actual mechanism (delegates to semver.Compare; non-canonical tags are treated as invalid and sort lowest) rather than implying deliberate release-preference logic.

  2. semver.compare (lowercase) is functionally valid — XGo resolves it to the exported semver.Compare — but both sibling comparator files use the canonical semver.Compare (internal/build/testdata/pnggroup/libpng/libpng_cmp.gox:2, internal/modules/testdata/DaveGamble/cJSON/CJSON_cmp.gox:2). Prefer semver.Compare for consistency. Those files also use 4-space indentation while this one uses tabs.

}
Loading