Skip to content

Commit ea5a566

Browse files
CopilotKaniska244
andauthored
Fix powershell preview/RC version installation failure
- Add -rc. version checks alongside preview checks in routing conditions so RC versions go directly to GitHub install instead of apt/dnf - Update find_preview_version_from_git_tags() to match -rc.X git tags - Fix typo googlegit_cmd_name -> git_cmd_name - Update preview test scripts to match both preview and rc.X patterns Co-authored-by: Kaniska244 <[email protected]> Agent-Logs-Url: https://github.com/devcontainers/features/sessions/03fd0565-a230-4bd9-80f7-92b8ce74a1bb
1 parent b5b41d8 commit ea5a566

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/powershell/install.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ find_preview_version_from_git_tags() {
126126
local requested_version=${!variable_name}
127127
local repository_url=$2
128128

129-
if [ -z "${googlegit_cmd_name}" ]; then
129+
if [ -z "${git_cmd_name}" ]; then
130130
if type git > /dev/null 2>&1; then
131131
git_cmd_name="git"
132132
else
@@ -135,22 +135,22 @@ find_preview_version_from_git_tags() {
135135
fi
136136
fi
137137

138-
# Fetch tags from remote repository
138+
# Fetch tags from remote repository (match both -preview.X and -rc.X tags)
139139
local tags
140-
tags=$(git ls-remote --tags "${repository_url}" 2>/dev/null | grep -oP 'refs/tags/v\K[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+' | sort -V)
140+
tags=$(git ls-remote --tags "${repository_url}" 2>/dev/null | grep -oP 'refs/tags/v\K[0-9]+\.[0-9]+\.[0-9]+-(preview|rc)\.[0-9]+' | sort -V)
141141

142142
if [ -z "${tags}" ]; then
143-
echo "No preview tags found in repository."
143+
echo "No preview/rc tags found in repository."
144144
return 1
145145
fi
146146

147147
local version=""
148148

149149
if [ "${requested_version}" = "preview" ] || [ "${requested_version}" = "latest" ]; then
150-
# Get the latest preview version
150+
# Get the latest preview/rc version
151151
version=$(echo "${tags}" | tail -n 1)
152152
elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+$ ]]; then
153-
# Partial version provided (e.g., "7.6"), find latest preview matching that major.minor
153+
# Partial version provided (e.g., "7.6"), find latest preview/rc matching that major.minor
154154
version=$(echo "${tags}" | grep "^${requested_version}\." | tail -n 1)
155155
elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-preview$ ]]; then
156156
# Version like "7.6.0-preview" provided, find latest preview for that version
@@ -161,6 +161,11 @@ find_preview_version_from_git_tags() {
161161
if echo "${tags}" | grep -q "^${requested_version}$"; then
162162
version="${requested_version}"
163163
fi
164+
elif [[ "${requested_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ ]]; then
165+
# Exact RC version provided, verify it exists
166+
if echo "${tags}" | grep -q "^${requested_version}$"; then
167+
version="${requested_version}"
168+
fi
164169
fi
165170

166171
if [ -z "${version}" ]; then
@@ -382,7 +387,7 @@ install_using_github() {
382387
fi
383388
pwsh_url="https://github.com/PowerShell/PowerShell"
384389
# Check if we need to find a preview version or stable version
385-
if [[ "${POWERSHELL_VERSION}" == *"preview"* ]] || [ "${POWERSHELL_VERSION}" = "preview" ]; then
390+
if [[ "${POWERSHELL_VERSION}" == *"preview"* ]] || [ "${POWERSHELL_VERSION}" = "preview" ] || [[ "${POWERSHELL_VERSION}" == *"-rc."* ]]; then
386391
echo "Finding preview version..."
387392
find_preview_version_from_git_tags POWERSHELL_VERSION "${pwsh_url}"
388393
else
@@ -446,9 +451,9 @@ if ! type pwsh >/dev/null 2>&1; then
446451
POWERSHELL_ARCHIVE_ARCHITECTURES="${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"
447452
fi
448453

449-
if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]]; then
454+
if [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_UBUNTU}"* ]] && [[ "${POWERSHELL_ARCHIVE_VERSION_CODENAMES}" = *"${VERSION_CODENAME}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]] && [[ "${POWERSHELL_VERSION}" != *"-rc."* ]]; then
450455
install_using_apt || use_github="true"
451-
elif [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]]; then
456+
elif [[ "${POWERSHELL_ARCHIVE_ARCHITECTURES}" = *"${POWERSHELL_ARCHIVE_ARCHITECTURES_ALMALINUX}"* ]] && [[ "${POWERSHELL_VERSION}" != *"preview"* ]] && [[ "${POWERSHELL_VERSION}" != *"-rc."* ]]; then
452457
install_using_dnf && install_powershell_dnf || use_github="true"
453458
else
454459
use_github="true"

test/powershell/powershell_preview_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
77

88
# Test preview version installation
99
check "pwsh is installed" bash -c "command -v pwsh"
10-
check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'"
10+
check "pwsh version is preview" bash -c "pwsh --version | grep -iE 'preview|rc\.[0-9]+'"
1111
check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'"
1212

1313
# Report result

test/powershell/powershell_preview_version_almalinux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
77

88
# Test preview version installation on AlmaLinux
99
check "pwsh is installed" bash -c "command -v pwsh"
10-
check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'"
10+
check "pwsh version is preview" bash -c "pwsh --version | grep -iE 'preview|rc\.[0-9]+'"
1111
check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'"
1212

1313
# Report result

test/powershell/powershell_preview_version_debian.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source dev-container-features-test-lib
77

88
# Test preview version installation on Debian
99
check "pwsh is installed" bash -c "command -v pwsh"
10-
check "pwsh version is preview" bash -c "pwsh --version | grep -i 'preview'"
10+
check "pwsh version is preview" bash -c "pwsh --version | grep -iE 'preview|rc\.[0-9]+'"
1111
check "pwsh can execute basic command" bash -c "pwsh -Command 'Write-Output Hello'"
1212

1313
# Report result

0 commit comments

Comments
 (0)