Skip to content

Commit 4f59d16

Browse files
committed
fix(ruby): accept both "_" and "." tag separators from ruby/ruby
ruby/ruby switched its release tag separator from "_" (e.g. v3_4_9) to "." (e.g. v4.0.4) starting at Ruby 4.0.0. The current regex in find_version_from_git_tags only matches the "_" form, so VERSION=latest and ADDITIONAL_VERSIONS resolution silently skip every 4.x release. When the caller passes "_" as the separator, build the regex with a [._] character class so both tag styles are picked up. The existing `tr "_" "."` normalization already produces correct dot-separated output for both forms, so downstream sort/grep logic is unchanged.
1 parent 8c47157 commit 4f59d16

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/ruby/install.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,20 @@ find_version_from_git_tags() {
150150
local last_part_optional=${5:-"false"}
151151
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
152152
local escaped_separator=${separator//./\\.}
153+
# ruby/ruby switched its tag separator from "_" (e.g. v3_4_5) to "." (e.g. v4.0.0)
154+
# starting at Ruby 4.0.0. When the caller asks for "_", accept either separator
155+
# so both tag styles are picked up; `tr "_" "."` below normalizes the result.
156+
local separator_regex="${escaped_separator}"
157+
if [ "${separator}" = "_" ]; then
158+
separator_regex="[._]"
159+
fi
153160
local last_part
154161
if [ "${last_part_optional}" = "true" ]; then
155-
last_part="(${escaped_separator}[0-9]+)?"
162+
last_part="(${separator_regex}[0-9]+)?"
156163
else
157-
last_part="${escaped_separator}[0-9]+"
164+
last_part="${separator_regex}[0-9]+"
158165
fi
159-
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
166+
local regex="${prefix}\\K[0-9]+${separator_regex}[0-9]+${last_part}$"
160167
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
161168
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
162169
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"

0 commit comments

Comments
 (0)