Skip to content

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.

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
@KrystianOcado
Copy link

Hi!

Any chance on merging this?

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.

3 participants