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

Fix failure to sort properly with prefix, sort double numbers (#43 #44). #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

john-tipper
Copy link

Tags were not being sorted properly if there was a prefix, as the numerical sort included the prefix in the first sort field. We grep this out via a capture group of the remainder of the tag, sort, then add the prefix back in if required. This also fixes the issue with double numbers.

The version being reported in get to the user (at the end of version-get()) was using an unsorted list of tags, so use the new sorted list for actually getting the version.

@@ -172,17 +172,22 @@ version-parse-pre-release() {
version-get() {
local sort_args version version_pre_releases pre_release_id_count pre_release_id_index
local tags=$(git tag)
local sorted_tags=$(
echo "$tags" |
grep -oP "^${VERSION_PREFIX}\K[0-9]+\.[0-9]+\.[0-9]+.*" |
Copy link

@endavid endavid Nov 2, 2020

Choose a reason for hiding this comment

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

This breaks on macOS because the P option does not exist.
In macOS, I replaced it with this and it worked:

perl -nle "m/^${VERSION_PREFIX}\K[0-9]+\.[0-9]+\.[0-9]+.*/ && print $&"

cmperaza added a commit to Whatnot-Inc/git-semver that referenced this pull request Feb 16, 2022
cmperaza added a commit to Whatnot-Inc/git-semver that referenced this pull request Feb 16, 2022
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

2 participants