Make upgrade command handle properly multi-upgrade in bash (#524)

This commit is contained in:
Pol Bassiner
2017-01-11 22:30:24 +01:00
committed by Marco Vermeulen
parent 8df496b5ae
commit 367a0718bd
3 changed files with 14 additions and 2 deletions

View File

@@ -65,8 +65,13 @@ function __sdk_upgrade {
read UPGRADE_ALL
export auto_answer_upgrade='true'
if [[ -z "$UPGRADE_ALL" || "$UPGRADE_ALL" == "y" || "$UPGRADE_ALL" == "Y" ]]; then
for upgradable_candidate in ${upgradable_candidates}; do
__sdk_install $upgradable_candidate
# Using array for bash & zsh compatibility
for (( i=0; i <= ${#upgradable_candidates[*]}; i++ )); do
upgradable_candidate="${upgradable_candidates[${i}]}"
# Filter empty elements (in bash arrays are zero index based, in zsh they are 1 based)
if [[ -n "$upgradable_candidate" ]]; then
__sdk_install $upgradable_candidate
fi
done
fi
unset auto_answer_upgrade

View File

@@ -63,14 +63,21 @@ Feature: Upgrade Candidate
Given the candidate "grails" version "1.3.9" is already installed and default
And the default "grails" version is "2.1.0"
And the candidate "grails" version "2.1.0" is available for download
And the candidate "groovy" version "2.0.5" is already installed and default
And the default "groovy" version is "2.4.1"
And the candidate "groovy" version "2.4.1" is available for download
And the system is bootstrapped
When I enter "sdk upgrade" and answer "Y"
Then I see "Upgrade:"
And I see "grails (1.3.9 < 2.1.0)"
And I see "groovy (2.0.5 < 2.4.1)"
And I see "Upgrade candidate(s) and set latest version(s) as default? (Y/n)"
And I do not see "Do you want grails 2.1.0 to be set as default? (Y/n)"
And I see "Setting grails 2.1.0 as default."
And I do not see "Do you want groovy 2.4.1 to be set as default? (Y/n)"
And I see "Setting groovy 2.4.1 as default."
Then the candidate "grails" version "2.1.0" should be the default
And the candidate "groovy" version "2.4.1" should be the default
Scenario: Don't update all upgradable candidates versions and set them as default
Given the candidate "grails" version "1.3.9" is already installed and default

View File

Binary file not shown.