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 sorting for prefixed semver #765

Merged
merged 1 commit into from
Jan 14, 2023

Conversation

IamTheFij
Copy link
Contributor

Strips non-numeric prefixes when checking semver. This also adds a secondary layer to the sort whereby identical semvers are sorted relative to eachother lexigraphically.

This will ensure a more stable sort for non-versioned tags (eg. latest or edge) as well as multiple variants tagged with the same number. (eg 1.0.0-alpine compared to 1.0.0-ubuntu).

Fixes #758

Strips non-numeric prefixes when checking semver. This also adds a
secondary layer to the sort whereby identical semvers are sorted
relative to eachother lexigraphically.

This will ensure a more stable sort for non-versioned tags (eg. `latest`
or `edge`) as well as multiple variants tagged with the same number.
(eg `1.0.0-alpine` compared to `1.0.0-ubuntu`).

Fixes crazy-max#758
@IamTheFij
Copy link
Contributor Author

Oh, I thought about using sort.SliceStable(), but decided against it. Since the final decision in the sort function is comparing the full tag lexicographical, there shouldn't be identical values as Docker shouldn't allow duplicate tag names.

Copy link
Owner

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@crazy-max crazy-max merged commit 4a0ff06 into crazy-max:master Jan 14, 2023
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.

Support semver sorting method for tags with a prefix
2 participants