Skip to content

Commit

Permalink
Add selfupdate_enable config and respect auto_answer when auto updating
Browse files Browse the repository at this point in the history
This also deprecates the auto_selfupdate config.
  • Loading branch information
felipecrs authored and marc0der committed Jul 12, 2021
1 parent cc1358b commit e557c9a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/bash/sdkman-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function sdk() {
fi

# Attempt upgrade after all is done
if [[ "$COMMAND" != "selfupdate" ]]; then
if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_enable" == true ]]; then
__sdkman_auto_update "$SDKMAN_REMOTE_VERSION" "$SDKMAN_VERSION"
fi
return $final_rc
Expand Down
2 changes: 1 addition & 1 deletion src/main/bash/sdkman-selfupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function __sdkman_auto_update() {
__sdkman_echo_no_colour "The current version is $remote_version, but you have $version."
echo ""

if [[ "$sdkman_auto_selfupdate" != "true" ]]; then
if [[ "$sdkman_auto_answer" == false ]]; then
__sdkman_echo_confirm "Would you like to upgrade now? (Y/n): "
read upgrade
fi
Expand Down
12 changes: 10 additions & 2 deletions src/test/resources/features/self_update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Feature: Self Update

Scenario: Automatically Selfupdate
Given an outdated initialised environment
And the configuration file has been primed with "sdkman_auto_selfupdate=true"
And the configuration file has been primed with "sdkman_auto_answer=true"
And the system is bootstrapped
When I enter "sdk help"
Then I see "A new version of SDKMAN is available..."
Expand All @@ -54,14 +54,22 @@ Feature: Self Update

Scenario: Do not automatically Selfupdate
Given an outdated initialised environment
And the configuration file has been primed with "sdkman_auto_selfupdate=false"
And the configuration file has been primed with "sdkman_auto_answer=false"
And the system is bootstrapped
When I enter "sdk help" and answer "n"
Then I see "A new version of SDKMAN is available..."
And I see "Would you like to upgrade now? (Y/n)"
And I see "Not upgrading today..."
And I do not see "Successfully upgraded SDKMAN."

Scenario: Do not check and prompt for update
Given an outdated initialised environment
And the configuration file has been primed with "sdkman_selfupdate_enable=false"
And the system is bootstrapped
When I enter "sdk help"
Then I do not see "A new version of SDKMAN is available..."
And I do not see "Would you like to upgrade now? (Y/n)"

Scenario: Bother the user with Upgrade message once a day
Given an outdated initialised environment
And the system is bootstrapped
Expand Down

0 comments on commit e557c9a

Please sign in to comment.