diff --git a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl index 6904af617..93072611c 100644 --- a/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl +++ b/src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl @@ -17,7 +17,6 @@ class {{brewFormulaName}} < Formula sdkman_auto_answer=false sdkman_auto_complete=true sdkman_auto_env=false - sdkman_auto_update=false sdkman_beta_channel=false sdkman_colour_enable=true sdkman_curl_connect_timeout=7 diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index d45c31990..8f9b7c407 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -149,10 +149,5 @@ function sdk() { __sdk_"$converted_command_name" "${@:2}" fi final_rc=$? - - # Attempt upgrade after all is done - if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_feature" == "true" && "$sdkman_auto_update" == "true" ]]; then - __sdkman_auto_update "$SDKMAN_REMOTE_VERSION" "$SDKMAN_VERSION" - fi return $final_rc } diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index 7e2b7753c..31af763bd 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -32,38 +32,3 @@ function __sdk_selfupdate() { __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable/${SDKMAN_PLATFORM}" | bash fi } - -function __sdkman_auto_update() { - local remote_version version delay_upgrade - - remote_version="$1" - version="$2" - delay_upgrade="${SDKMAN_DIR}/var/delay_upgrade" - - if [[ -n "$(find "$delay_upgrade" -mtime +1)" && "$remote_version" != "$version" ]]; then - echo "" - echo "" - __sdkman_echo_yellow "ATTENTION: A new version of SDKMAN is available..." - echo "" - __sdkman_echo_no_colour "The current version is $remote_version, but you have $version." - echo "" - - if [[ "$sdkman_auto_answer" == false ]]; then - __sdkman_echo_confirm "Would you like to upgrade now? (Y/n): " - read upgrade - fi - - if [[ -z "$upgrade" ]]; then - upgrade="Y" - fi - - if [[ "$upgrade" == "Y" || "$upgrade" == "y" ]]; then - __sdk_selfupdate "force" - unset upgrade - else - __sdkman_echo_no_colour "Not upgrading today..." - fi - - touch "$delay_upgrade" - fi -} diff --git a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy index 4ba6a55e8..1d7a5dae6 100644 --- a/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/SelfupdateSpec.groovy @@ -57,35 +57,4 @@ class SelfupdateSpec extends SdkmanEnvSpecification { "false" | { it.contains("Invalid command: selfupdate") } "true" | { it.contains("No update available at this time.") } } - - def "should perform an autoupdate when the selfupdate feature is toggled on and autoupdate is enabled"() { - given: - new File("$sdkmanDotDirectory/var/delay_upgrade").with { - parentFile.mkdirs() - createNewFile() - lastModified = Instant.now().minus(2, DAYS).toEpochMilli() - } - - bash = sdkmanBashEnvBuilder - .withSdkmanVersion("4.0.0") - .withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) - .withConfiguration("sdkman_auto_update", autoUpdateEnabled) - .withConfiguration("sdkman_auto_answer", "true") - .build() - - bash.start() - bash.execute("source $bootstrapScript") - - when: - bash.execute("sdk version") - - then: - verifyOutput(bash.output) - - where: - selfupdateFeature | autoUpdateEnabled | verifyOutput - "true" | "true" | { it.contains("ATTENTION: A new version of SDKMAN is available...") } - "true" | "false" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } - "false" | "true" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } - } } diff --git a/src/test/resources/features/self_update.feature b/src/test/resources/features/self_update.feature index 2baf8252a..8ef34fe9e 100644 --- a/src/test/resources/features/self_update.feature +++ b/src/test/resources/features/self_update.feature @@ -14,75 +14,6 @@ Feature: Self Update And I see "Updating SDKMAN..." And I see "Successfully upgraded SDKMAN." - Scenario: Selfupdate when out of date - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk selfupdate" - 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)" - And I do not see "Not upgrading today..." - And I see "Updating SDKMAN..." - And I see "Successfully upgraded SDKMAN." - - Scenario: Agree to a suggested Selfupdate - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk help" and answer "Y" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Successfully upgraded SDKMAN." - And I do not see "Not upgrading today..." - - Scenario: Do not agree to a suggested Selfupdate - Given an outdated initialised environment - 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: Automatically Selfupdate - Given an outdated initialised environment - 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..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Successfully upgraded SDKMAN." - - Scenario: Do not automatically Selfupdate - Given an outdated initialised environment - 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 - 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 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)" - And I do not see "Not upgrading now..." - And I do not see "Successfully upgraded SDKMAN." - Scenario: Selfupdate when not out of date Given an initialised environment And the system is bootstrapped