Skip to content

Conversation

@Trenly
Copy link
Contributor

@Trenly Trenly commented Nov 25, 2024

Cherry Pick #5001 into release-v1.9

Microsoft Reviewers: Open in CodeFlow

<!-- To check a checkbox place an "x" between the brackets. e.g: [x] -->

- [x] I have signed the [Contributor License
Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs).
- [x] This pull request is related to an issue.
  - Resolves microsoft#4998 

When versions are created, any empty parts are trimmed off. This means
that `22.0.0` is stored as `[22]` in memory. This causes an issue when
comparing to a version that had additional parts, but should be sorted
lower than the version which is trimmed, such as `22.0.0-rc`. This is
due to the comparator seeing that `[22]` has no more parts to compare
after the first iteration, while `[22, 0, 0-rc]` does, causing it to hit
the condition where whichever version has more parts is considered to be
greater.

This PR updates the logic so that the version comparison effectively
contains as many empty parts as are needed to fully complete the
comparison. This retains the logic that if a part is not equal to the
part it is being compared against, the result of that comparison will be
returned but eliminates the need for checking if the versions have the
same number of parts since, effectively, they do; it's just that the
extra parts needed to complete the comparison are all empty.

Additional tests have been added to cover this corner case.

If possible, I would ask that this also be cherry-picked into any future
1.9 releases (assuming this PR passes review and merges)
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5001)
@Trenly Trenly requested a review from a team as a code owner November 25, 2024 19:44
@florelis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@florelis florelis merged commit 85589d0 into microsoft:release-v1.9 Dec 2, 2024
4 checks passed
@Trenly Trenly deleted the release-v1.9 branch December 23, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants