mirror of
https://github.com/reecetech/version-increment.git
synced 2025-12-21 06:25:44 +00:00
Don't auto-add @ to prefix; Shift utility function
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user