nexus-cli icon indicating copy to clipboard operation
nexus-cli copied to clipboard

Add semver sort option for tags listing and delete with -keep

Open KarolBuchta opened this issue 6 years ago • 2 comments

Description

Add semver sort option when listing tags as well as when using the keep flag when deleting. This ways it is possible to retain the last X versions. Used an exception for 'latest' tag.

The existing numeric sort breaks when you say you want to keep the last 5 versions:

` 1.0.1

1.0.11

1.1.0

2.0.0-alpha

2.0.0-beta

2.0.0

latest `

As one can see, with the current numeric sort the order of 1.0.11 - 1.1.0 would be wrong wit numeric sort. In Semver it's 1.0.11 < 1.1.0. When using numeric sort it's 1.0.11 > 1.1.0 (wrong).

Hence I added an option for sorting -sort (default | semver)

Related Issue

#5

Changes proposed

Simply adding a good semver lib and an additional command line flag for tags listing and delete when using the keep option. Also updated the README.md.

Screenshots

No screenshots, the description and the listing of the versions should be sufficient to explain the problem and its solution.

KarolBuchta avatar Jul 31 '18 09:07 KarolBuchta

Is there any chance getting this merged and released? Thank you very much!

anpieber avatar Mar 26 '20 10:03 anpieber

Hi @KarolBuchta

I see if we have tags with build number and git hash in them then sorting doesn't work as expected. 0.0.2-11 > 0.0.2-2 while it shows different.

./new-nexus-cli image tags -name pi-service --sort semver 0.0.2-11-gc6093c2 0.0.2-2-g18982e7 0.0.2-30-g134c5a1 0.0.2-43-gb86968d 0.0.2-48-g6b37682 0.1.1

sort -V return the correct output. is there a way to have same in golang. ./new-nexus-cli image tags -name api-service | sort -V 0.0.2-2-g18982e7 0.0.2-11-gc6093c2 0.0.2-30-g134c5a1 0.0.2-43-gb86968d 0.0.2-48-g6b37682 0.1.1

adityagu0910 avatar Aug 19 '20 21:08 adityagu0910