Tarun4201 commented on issue #8873:
URL: https://github.com/apache/maven/issues/8873#issuecomment-6126118907

   ### [MNG-7594] Fix ComparableVersion getCanonical for zero between hyphens
   
   #### Summary
   Resolves the issue where version strings like `1-0-1` had contradictory 
canonicalization and comparison results. Previously, `ListItem.normalize()` 
removed intermediate zero elements before child lists, resulting in `1-0-1` 
being canonicalized to `1-1` while still sorting as `1-0-1 < 1-1`.
   
   #### Changes
   1. **`ListItem.normalize()`**:
      - Added safe pattern matching and non-empty guards when inspecting 
following `ListItem` entries before determining if preceding null/zero items 
can be pruned.
   2. **Regression Tests (`ComparableVersionTest#testMng7594`)**:
      - Verified that `1-0-1` canonicalizes to `1-0-1` and compares equal to 
`1--1`.
      - Verified `1-0-1 < 1-1` and `canonical("1-0-1") != canonical("1-1")`.
      - Covered related zero-between-hyphen cases (e.g. `1-0-2 < 1-0.1 < 1-2` 
from MNG-6420, multiple hyphenated zeros `1-0-0-1`, and normalized trailing 
zeros like `1-0-1-0 == 1-0-1`).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to