arturobernalg opened a new pull request, #13572:
URL: https://github.com/apache/maven/pull/13572

   ## What and why
   
   On 3.10.x `ComparableVersion#getCanonical()` turns `1-0-1` into `1-1`, 
although the two compare differently (`1-0-1` < `1-1`). The parsed form is `[1, 
[[1]]]`, a list nested in a list, and `ListItem.toString()` only wrote the 
hyphen of a nested list when something had already been written before it, so 
the inner hyphen was lost (#8873).
   
   The issue is already fixed on master and 4.0.x by #13102, which also changes 
how `1.0-1` and `1-1` compare. That change is not backported here: the 3.x 
ordering stays as it is.
   
   ## How
   
   `ListItem.toString()` always writes the hyphen of a nested list. `1-0-1` is 
now `1--1`, which parses back to an equal version, and `1-0-0-1` is `1---1`. 
Versions without a nested list in first position, such as `1-1` and `1.0-1`, 
keep their canonical form. Comparison is not touched.
   
   ## Tests
   
   `ComparableVersionTest#testMng7594` fails without the change. 
`maven-artifact`, `maven-resolver-provider` and `maven-core` pass (420 tests) 
and spotless is clean. A random check of 60000 versions found 16932 whose 
canonical form did not parse back to an equal version before, and 956 after. 
The remaining ones involve empty tokens and `ga`, and are not part of this 
change.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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