Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ruby/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "ruby",
"version": "1.3.2",
"version": "1.3.3",
"name": "Ruby (via rvm)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/ruby",
"description": "Installs Ruby, rvm, rbenv, common Ruby utilities, and needed dependencies.",
Expand Down
18 changes: 9 additions & 9 deletions src/ruby/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ find_version_from_git_tags() {
local repository=$2
local prefix=${3:-"tags/v"}
local separator=${4:-"."}
local last_part_optional=${5:-"false"}
local last_part_optional=${5:-"false"}
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
local escaped_separator=${separator//./\\.}
local last_part
if [ "${last_part_optional}" = "true" ]; then
last_part="(${escaped_separator}[0-9]+)?"
last_part="(\\.[0-9]+)?"
else
last_part="${escaped_separator}[0-9]+"
last_part="\\.[0-9]+"
fi
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
local regex="${prefix}\\K[0-9]+\\.[0-9]+${last_part}$"
# ruby/ruby switched its tag separator from "_" (v3_4_5) to "." (v4.0.0) at v4.0.0
local version_list="$(git ls-remote --tags ${repository} | tr "_" "." | grep -oP "${regex}" | tr -d ' ' | sort -rV)"
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
else
Expand Down Expand Up @@ -280,7 +280,7 @@ get_previous_version() {
if [[ $message == "API rate limit exceeded"* ]]; then
echo -e "\nAn attempt to find latest version using GitHub Api Failed... \nReason: ${message}"
echo -e "\nAttempting to find latest version using GitHub tags."
find_prev_version_from_git_tags prev_version "$url" "tags/v" "_"
find_prev_version_from_git_tags prev_version "$url" "tags/v"
declare -g ${variable_name}="${prev_version}"
else
echo -e "\nAttempting to find latest version using GitHub Api."
Expand All @@ -299,7 +299,7 @@ get_github_api_repo_url() {
# Figure out correct version of a three part version number is not passed
RUBY_URL="https://github.com/ruby/ruby"
ORIGINAL_RUBY_VERSION=$RUBY_VERSION
find_version_from_git_tags RUBY_VERSION $RUBY_URL "tags/v" "_"
find_version_from_git_tags RUBY_VERSION $RUBY_URL "tags/v"

set_rvm_install_args() {
RUBY_VERSION=$1
Expand Down Expand Up @@ -379,7 +379,7 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
read -a additional_versions <<< "$ADDITIONAL_VERSIONS"
for version in "${additional_versions[@]}"; do
# Figure out correct version of a three part version number is not passed
find_version_from_git_tags version $RUBY_URL "tags/v" "_"
find_version_from_git_tags version $RUBY_URL "tags/v"
source /usr/local/rvm/scripts/rvm
rvm install ruby ${version}
done
Expand Down
2 changes: 2 additions & 0 deletions test/ruby/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ source dev-container-features-test-lib
check "ruby version" ruby --version
check "gem version" gem --version

check "ruby version uses dot separator" bash -c "ruby --version | grep -oP '\d+\.\d+\.\d+'"

# Report result
reportResults