Skip to content

Commit

Permalink
fix version matching
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Aug 10, 2023
1 parent 567ce55 commit 8736b99
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/rstudio-server/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,22 @@ check_packages() {
find_version_from_git_tags() {
local variable_name=$1
local requested_version=${!variable_name}
local tmp
if [ "${requested_version}" = "none" ]; then return; fi
local repository=$2
local prefix=${3:-"tags/v"}
local separator=${4:-"."}
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
local escaped_separator=${separator//./\\.}
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${escaped_separator}[0-9]+\\+[0-9]+$"
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${escaped_separator}[0-9]+\+[0-9]+$"
local version_list
version_list="$(git ls-remote --tags "${repository}" | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
declare -g "${variable_name}"="$(echo "${version_list}" | head -n 1)"
else
tmp=${requested_version//+/\\+}
set +e
declare -g "${variable_name}"="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
declare -g "${variable_name}"="$(echo "${version_list}" | grep -E -m 1 "^${tmp//./\\.}([\\.\\s]|$)")"
set -e
fi
fi
Expand Down

0 comments on commit 8736b99

Please sign in to comment.