Don't auto-add @ to prefix; Shift utility function

This commit is contained in:
Phil Jay
2024-08-31 13:49:15 +10:00
parent aa4572b10f
commit d4496413d6
4 changed files with 22 additions and 30 deletions

View File

@@ -23,21 +23,6 @@ fi
##==----------------------------------------------------------------------------
## Version parsing
# Function to extract the semver part from the tag
extract_semver() {
local tag="$1"
if [[ -n "${tag_prefix:-}" ]]; then
# Escape special characters in tag_prefix
local escaped_prefix
escaped_prefix=$(printf '%s\n' "$tag_prefix" | sed 's/[][\/.^$*]/\\&/g')
# Use | as the delimiter to avoid conflicts with /
echo "${tag}" | sed "s|^${escaped_prefix}||"
else
echo "${tag}"
fi
}
# detect current version - removing "v" from start of tag if it exists
if [[ "${use_api:-}" == 'true' ]] ; then
current_version="$(
@@ -49,7 +34,7 @@ if [[ "${use_api:-}" == 'true' ]] ; then
| jq -r '.[].ref' | sed 's|refs/tags/||g' \
| { grep_p "${pcre_allow_vprefix}" || true; } \
| sed 's/^v//g' \
| while read -r tag; do extract_semver "$tag"; done \
| while read -r tag; do remove_prefix "$tag"; done \
| sort -V | tail -n 1
)"
else
@@ -57,7 +42,7 @@ else
git tag -l \
| { grep_p "${pcre_allow_vprefix}" || true; } \
| sed 's/^v//g' \
| while read -r tag; do extract_semver "$tag"; done \
| while read -r tag; do remove_prefix "$tag"; done \
| sort -V | tail -n 1
)"
fi