Regex versioning: build group is compared before prerelease, making timestamp-based build numbers override prerelease ordering #44331
Unanswered
XiyangDong
asked this question in
Request Help
Replies: 3 comments 1 reply
-
|
+1 to adding an option to change the ordering. I dont think this should be changed as default. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I disagree, because it would break a lot other use cases, eg |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Is there anyway we can have regex that satisfy |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
How are you running Renovate?
None
Which platform you running Renovate on?
None
Which version of Renovate are you using?
v43.128.1
Please tell us more about your question or problem
Problem
When using regex versioning with both
prereleaseandbuildcapture groups, thebuildvalue is compared as part of the release array before
prereleaseis ever evaluated. Thismakes it impossible to correctly order tags that have an optional pre-release phase and
a build timestamp.
Our tag format
We publish container images with this tagging convention:
The intended ordering is:
Within the same EA level, the build timestamp should act as a tiebreaker (multiple builds
can be published for the same EA phase).
Our versioning regex
What happens
Renovate proposed updating from
3.5.0-ea.2-1778760581to3.5.0-ea.1-1780597972becausethe build timestamp
1780597972 > 1778760581. The EA level (ea.1 < ea.2) was ignored.Parsing the two versions:
_compare()inlib/modules/versioning/generic.tscompares the release array[major, minor, patch, build]left-to-right and returns on the first difference. Sincebuildis in the array, it is compared beforeprereleaseis ever checked. The comparisonstops at
1780597972 > 1778760581and declares ea.1 newer. The prerelease comparison(
"2" > "1") never runs.The same problem affects GA vs EA ordering: GA wins only because its build timestamp
happens to be higher. If an EA build ever had a higher timestamp than the GA build, it
would rank above GA — ordering by accident, not by design.
Root cause
In
lib/modules/versioning/regex/index.ts,_parse()appends thebuildcapture groupas a numeric element of the
releasearray:[major, minor, patch, build?, revision?].In
lib/modules/versioning/generic.ts,_compare()compares the release arrayexhaustively before consulting
prerelease. There is no way for a user to change thisorder via configuration.
Why existing workarounds don't work
compatibilityfor the build timestampprereleasestring (e.g.ea.2-1778760581)localeComparewithnumeric: truedoes not reliably sort mixed alpha-numeric strings likeea.2-1778760581vsea.1-1780597972.ignoreUnstable: falseProposed fix
The comparison order should be:
rather than the current:
One approach: introduce a way to mark the
buildgroup as a "post-prerelease tiebreaker"so it is evaluated after
prerelease, not before. This could be an opt-in flag in theregex versioning config (e.g.
buildIsPostPrerelease: true) to avoid changing the defaultbehavior for existing users.
Environment
References
lib/modules/versioning/regex/index.ts—_parse(), wherebuildis pushed into the release arraylib/modules/versioning/generic.ts—_compare(), where the release array is compared before prereleaseLogs (if relevant)
Logs
Beta Was this translation helpful? Give feedback.
All reactions