Repository navigation
Fix VersionInformation ordering for a higher bugfix with a lower build - #636
Conversation
operator< compared the build number even when the bugfix of the left operand was higher, so 5.9.4.100 < 5.9.3.200 was true (and so was the reverse). The other relational operators are derived from operator<, so they were wrong for the same inputs. Only compare the build number when major, minor and bugfix are equal.
PR SummaryMedium Risk Overview Because Reviewed by Cursor Bugbot for commit ab3a952. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
This pull request is merged. |
urfeex
left a comment
There was a problem hiding this comment.
That absolutely makes sense, thank you!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #636 +/- ##
==========================================
- Coverage 83.90% 83.89% -0.01%
==========================================
Files 128 128
Lines 8564 8565 +1
Branches 3914 3914
==========================================
Hits 7186 7186
+ Misses 967 965 -2
- Partials 411 414 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
The three red checks were outside this diff. The pull request was already merged, so no rerun is needed.
|
Summary
VersionInformation::operator<went on to compare build numbers after major and minor had matched, including when the left-hand bugfix was already higher. Both of these were therefore true at once:<=,>and>=are written in terms of<, so they gave the wrong answer for the same inputs.fromString("5.9.4") > fromString("5.9.3.1010107")was false.The build comparison was one brace outside the
bugfix <=block. It now runs only when major, minor and bugfix are equal.Comparisons inside the library pass a version constant with no build number (
5.9.4,10.0.0, and so on), and those results stay the same. The operator is public, and the wrong order shows up when both sides carry a build. A script template does that when the literal includes one, for example{% if ROBOT_SOFTWARE_VERSION >= v5.9.3-200 %}: on a robot reporting5.9.4.100that condition took the wrong branch.I searched the issue tracker for VersionInformation and did not find an existing report.
If you would rather have the body as
std::tie(major, minor, bugfix, build), I can switch it.Validation
test_relations_higher_bugfix_with_lower_build. It fails on the previous operator and passes with this change. The wholeversion_information_testsbinary passes (7 tests), including on this machine with AppleClang.TestHelpers.writeFileAtomicallyUnwritableDirectory).src/ur/version_information.cppandtests/test_version_information.cpp.