Skip to content

Commit

Permalink
Remove auto-update feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0der committed Mar 4, 2023
1 parent a89a8cc commit 4b172a6
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 141 deletions.
1 change: 0 additions & 1 deletion src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/main/bash/sdkman-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
35 changes: 0 additions & 35 deletions src/main/bash/sdkman-selfupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
31 changes: 0 additions & 31 deletions src/test/groovy/sdkman/specs/SelfupdateSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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...") }
}
}
69 changes: 0 additions & 69 deletions src/test/resources/features/self_update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4b172a6

Please sign in to comment.