mirror of
https://github.com/reecetech/version-increment.git
synced 2025-12-20 22:15:43 +00:00
Fix tests; Pre-filter tags
This commit is contained in:
@@ -12,7 +12,6 @@ export LC_ALL=C.UTF-8
|
|||||||
pcre_semver='^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
|
pcre_semver='^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
|
||||||
pcre_master_ver='^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$'
|
pcre_master_ver='^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$'
|
||||||
pcre_allow_vprefix="^v{0,1}${pcre_master_ver:1}"
|
pcre_allow_vprefix="^v{0,1}${pcre_master_ver:1}"
|
||||||
|
|
||||||
pcre_old_calver='^(?P<major>0|[1-9]\d*)-0{0,1}(?P<minor>0|[0-9]\d*)-R(?P<patch>0|[1-9]\d*)$'
|
pcre_old_calver='^(?P<major>0|[1-9]\d*)-0{0,1}(?P<minor>0|[0-9]\d*)-R(?P<patch>0|[1-9]\d*)$'
|
||||||
|
|
||||||
##==----------------------------------------------------------------------------
|
##==----------------------------------------------------------------------------
|
||||||
@@ -25,6 +24,10 @@ remove_prefix() {
|
|||||||
local escaped_prefix
|
local escaped_prefix
|
||||||
escaped_prefix=$(printf '%s\n' "$tag_prefix" | sed 's/[][\/.^$*]/\\&/g')
|
escaped_prefix=$(printf '%s\n' "$tag_prefix" | sed 's/[][\/.^$*]/\\&/g')
|
||||||
|
|
||||||
|
if [[ -z "$(echo "${tag}" | grep "^${tag_prefix}")" ]] ; then
|
||||||
|
echo ""
|
||||||
|
return
|
||||||
|
fi
|
||||||
# Use | as the delimiter to avoid conflicts with /
|
# Use | as the delimiter to avoid conflicts with /
|
||||||
echo "${tag}" | sed "s|^${escaped_prefix}||"
|
echo "${tag}" | sed "s|^${escaped_prefix}||"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ function init_repo {
|
|||||||
@test "finds the current normal version with tag_prefix enabled" {
|
@test "finds the current normal version with tag_prefix enabled" {
|
||||||
init_repo
|
init_repo
|
||||||
|
|
||||||
export tag_prefix="@org/product"
|
export tag_prefix="@org/product@"
|
||||||
|
|
||||||
git tag @org/product@0.0.1
|
git tag @org/product@0.0.1
|
||||||
git tag @org/product@0.1.1
|
git tag @org/product@0.1.1
|
||||||
@@ -91,9 +91,9 @@ function init_repo {
|
|||||||
@test "tag_prefix enabled prefixes with a v" {
|
@test "tag_prefix enabled prefixes with a v" {
|
||||||
init_repo
|
init_repo
|
||||||
|
|
||||||
export tag_prefix="@org/product"
|
export tag_prefix="@org/product/"
|
||||||
|
|
||||||
git tag @org/product@0.1.2
|
git tag @org/product/0.1.2
|
||||||
|
|
||||||
run version-lookup.sh
|
run version-lookup.sh
|
||||||
|
|
||||||
@@ -119,10 +119,10 @@ function init_repo {
|
|||||||
@test "finds only prefixed tags when tag_prefix set" {
|
@test "finds only prefixed tags when tag_prefix set" {
|
||||||
init_repo
|
init_repo
|
||||||
|
|
||||||
export tag_prefix="@org/product"
|
export tag_prefix="my_product-"
|
||||||
|
|
||||||
git tag @org/product@0.1.2
|
git tag my_product-0.1.2
|
||||||
git tag @org/product@0.1.3-dev.123
|
git tag my_product-0.1.3-dev.123
|
||||||
git tag 2.4.5
|
git tag 2.4.5
|
||||||
git tag 2.4.6-dev.456
|
git tag 2.4.6-dev.456
|
||||||
|
|
||||||
|
|||||||
@@ -32,17 +32,17 @@ if [[ "${use_api:-}" == 'true' ]] ; then
|
|||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/" \
|
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/" \
|
||||||
| jq -r '.[].ref' | sed 's|refs/tags/||g' \
|
| jq -r '.[].ref' | sed 's|refs/tags/||g' \
|
||||||
|
| while read -r tag; do remove_prefix "$tag"; done \
|
||||||
| { grep_p "${pcre_allow_vprefix}" || true; } \
|
| { grep_p "${pcre_allow_vprefix}" || true; } \
|
||||||
| sed 's/^v//g' \
|
| sed 's/^v//g' \
|
||||||
| while read -r tag; do remove_prefix "$tag"; done \
|
|
||||||
| sort -V | tail -n 1
|
| sort -V | tail -n 1
|
||||||
)"
|
)"
|
||||||
else
|
else
|
||||||
current_version="$(
|
current_version="$(
|
||||||
git tag -l \
|
git tag -l \
|
||||||
|
| while read -r tag; do remove_prefix "$tag"; done \
|
||||||
| { grep_p "${pcre_allow_vprefix}" || true; } \
|
| { grep_p "${pcre_allow_vprefix}" || true; } \
|
||||||
| sed 's/^v//g' \
|
| sed 's/^v//g' \
|
||||||
| while read -r tag; do remove_prefix "$tag"; done \
|
|
||||||
| sort -V | tail -n 1
|
| sort -V | tail -n 1
|
||||||
)"
|
)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user