Skip to content

Commit

Permalink
Fix parsing composer version when snapshot is stable
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Dec 22, 2021
1 parent 0f13e29 commit 65341e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/scripts/win32.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down

0 comments on commit 65341e4

Please sign in to comment.