I already wrote about Version-String handling in the past, and because it is a topic that I have to deal with regularly (we are using a migration-based delivery strategy with version numbering), I finally wrote a little utility package to make life easier.
It looks as follows:
- Spec
- Body
Spec
Body
You can find the whole package (and accompanying unit-tests) in the SithDB repo.
Sorting done simple
Sorting any list of versionstrings or formatting them with different leading 0s is now dead simple:
Version | Version 2 Zero |
---|---|
1.5.001 | .01.05.01 |
1.5.18.29 | .01.05.18.29 |
1.5.185.3 | .01.05.185.03 |
1.6 | .01.06 |
2 | .02 |
2.04.1 | .02.04.01 |
2.4.3 | .02.04.03 |
12.4.1 | .12.04.01 |
As is normalizing the version into some readable format with no zeros at all:
Version |
---|
1.5 |
1.5.1 |
1.5.18.29 |
1.5.185.3 |
1.6 |
2 |
2.4.1 |
2.4.3 |
12.4.1 |
Fun with Grouping
But what if we want to know the max version?
Max Version |
---|
12.4.1 |
Or if we want to know what major versions we have and how many versions belong to each major version?
Major Version | Number of Versions |
---|---|
1 | 5 |
2 | 3 |
12 | 1 |
9 |
Or the latest version of each major version?
Major Version | Latest Version |
---|---|
1 | 1.6 |
2 | 2.4.3 |
12 | 12.4.1 |
Have fun!
Remember – SQL is your friend!
0 Comments