Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KarolBuchta
Copy link

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.

kb added 2 commits July 31, 2018 11:08
…ep flag when deleting. This ways it is possible to retain the last X versions. Used an exception for 'latest' tag.
@anpieber
Copy link

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

@adityagu0910
Copy link

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

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.

None yet

3 participants