From 65341e4a6dc3937d49b8e49e2c488aa26a7b8fdb Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 22 Dec 2021 22:34:35 +0530 Subject: [PATCH] Fix parsing composer version when snapshot is stable --- src/scripts/common.sh | 7 ++++--- src/scripts/win32.ps1 | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/scripts/common.sh b/src/scripts/common.sh index 4ba7406d..a8fad1d8 100644 --- a/src/scripts/common.sh +++ b/src/scripts/common.sh @@ -261,10 +261,11 @@ get_tool_version() { alp="[a-zA-Z0-9]" version_regex="[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}" if [ "$tool" = "composer" ]; then - if [ "$param" != "snapshot" ]; then - composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")" + composer_alias_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")" + if [[ -n "$composer_alias_version" ]]; then + composer_version="$composer_alias_version+$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$alp+" | tail -n 1)" else - composer_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")+$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)" + composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")" fi echo "$composer_version" | sudo tee /tmp/composer_version else diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 28c43859..4a38d9a8 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -345,8 +345,9 @@ Function Get-ToolVersion() { $alp = "[a-zA-Z0-9]" $version_regex = "[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}" if($tool -eq 'composer') { - if ($param -eq 'snapshot') { - $composer_version = (Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }) + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value }) + $composer_branch_alias = Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value } + if ($composer_branch_alias) { + $composer_version = $composer_branch_alias + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value }) } else { $composer_version = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value } }