Skip to content

Conversation

@Ankush1oo8
Copy link

Please provide a summary of your changes here.

  • Added VersionComparator in common/utils for accurate version sorting
  • Updated iterateProjectRelationShips methods to use VersionComparator
  • Improved sorting logic for project links based on name and version
  • Ensured compatibility with existing project relationship handling

Issue: #236

Suggest Reviewer

How To Test?

  1. Run the SW360 backend and verify project relationships are sorted correctly.
  2. Ensure no functionality is broken by running tests.
  3. Validate the sorting logic using different project versions.

Checklist

Must:

  • All related issues are referenced in commit messages and in PR

@GMishx GMishx added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for labels Mar 10, 2025
@Ankush1oo8 Ankush1oo8 force-pushed the feature/version-comparator-update branch from 001a785 to 0c40917 Compare March 11, 2025 12:04
@Ankush1oo8 Ankush1oo8 requested a review from GMishx March 11, 2025 12:21
Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

A small change is still required.

@Ankush1oo8 Ankush1oo8 force-pushed the feature/version-comparator-update branch from 2bf2048 to a414daa Compare March 13, 2025 08:32
@Ankush1oo8 Ankush1oo8 requested a review from GMishx March 13, 2025 08:33
@Ankush1oo8
Copy link
Author

@GMishx can you check now

@Ankush1oo8
Copy link
Author

Ankush1oo8 commented Mar 13, 2025

Why This Works

If part = "43-2+deb8u2", numericPrefix = "43", which can be parsed safely.

If part has no numeric prefix (e.g., "deb8u2"), it gets a default -1 for lower priority.

It ensures that versions like "3.16.43-2+deb8u2" are still sorted meaningfully.

@Ankush1oo8
Copy link
Author

@GMishx can you check now

@Ankush1oo8
Copy link
Author

@GMishx should I also optimise for version with aplha or beta

@GMishx
Copy link
Member

GMishx commented Mar 13, 2025

Why This Works

If part = "43-2+deb8u2", numericPrefix = "43", which can be parsed safely.

If part has no numeric prefix (e.g., "deb8u2"), it gets a default -1 for lower priority.

It ensures that versions like "3.16.43-2+deb8u2" are still sorted meaningfully.

I agree but current solution works for cases like 1.2.2 < 1.2.3

Will work for the Debian version strings.

But would say v1.3.2 > v2.1.1

The solution should be generic enough.

@Ankush1oo8 Ankush1oo8 requested a review from GMishx March 13, 2025 17:32
@Ankush1oo8
Copy link
Author

@GMishx I have also added for
Handles epoch versions (1:2.3.4 vs 2.3.4) correctly
Ignores build metadata (1.2.3+build.4 == 1.2.3)
Normalizes leading zeros (01.02.003 == 1.2.3)
Supports configurable pre-release precedence (alpha < beta < rc)
Optimized with caching for performance

Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

I'd call it "over-engineered" solution to a simple problem of returning 0 if the conversion to int failed.

However, it looks good to me. But I'd like to have second opinion from @shi9qiu or @hoangnt2

@GMishx
Copy link
Member

GMishx commented Apr 28, 2025

@shi9qiu can you please help test / review this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs code review needs general test This is general testing, meaning that there is no org specific issue to check for

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants