fix: java version comparison fails #889
Open
+58
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
This PR adds a protecting logic to the version comparison. Currently, we are comparing Java versions string with a pip version utility that is not 100% compatible.
Closes #886
Expected behavior:
Explain and/or show screenshots for how you expect the pull request to work in your testing (in case other devices exhibit different behavior).
Testing tips:
The fastest way to test this PR is using a PR that changes the UI deployed to DEV.
From our AI friend
This pull request introduces a new utility function for comparing Java version strings and integrates it into the existing codebase. The most important changes include the creation of the
compare_java_versions
function, its integration into theGtfsDatasetImpl
andLatestDatasetImpl
classes, and the addition of unit tests for the new function.New Utility Function:
api/src/utils/model_utils.py
: Added thecompare_java_versions
function to compare two Java version strings, including handling of-SNAPSHOT
suffixes.Integration of Utility Function:
api/src/feeds/impl/models/gtfs_dataset_impl.py
: Replaced the use ofVersion
with the newcompare_java_versions
function in thefrom_orm_latest_validation_report
method. [1] [2]api/src/feeds/impl/models/latest_dataset_impl.py
: Replaced the use ofVersion
with the newcompare_java_versions
function in thefrom_orm
method. [1] [2]Unit Tests:
api/tests/utils/test_compare_java_versions.py
: Added unit tests for thecompare_java_versions
function to ensure it correctly compares version strings, including cases withNone
values and-SNAPSHOT
suffixes.Please make sure these boxes are checked before submitting your pull request - thanks!
./scripts/api-tests.sh
to make sure you didn't break anything