Skip to content

Commit 4b172a6

Browse files
committed
Remove auto-update feature.
1 parent a89a8cc commit 4b172a6

File tree

5 files changed

+0
-141
lines changed

5 files changed

+0
-141
lines changed

src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class {{brewFormulaName}} < Formula
1717
sdkman_auto_answer=false
1818
sdkman_auto_complete=true
1919
sdkman_auto_env=false
20-
sdkman_auto_update=false
2120
sdkman_beta_channel=false
2221
sdkman_colour_enable=true
2322
sdkman_curl_connect_timeout=7

src/main/bash/sdkman-main.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,5 @@ function sdk() {
149149
__sdk_"$converted_command_name" "${@:2}"
150150
fi
151151
final_rc=$?
152-
153-
# Attempt upgrade after all is done
154-
if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_feature" == "true" && "$sdkman_auto_update" == "true" ]]; then
155-
__sdkman_auto_update "$SDKMAN_REMOTE_VERSION" "$SDKMAN_VERSION"
156-
fi
157152
return $final_rc
158153
}

src/main/bash/sdkman-selfupdate.sh

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,3 @@ function __sdk_selfupdate() {
3232
__sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable/${SDKMAN_PLATFORM}" | bash
3333
fi
3434
}
35-
36-
function __sdkman_auto_update() {
37-
local remote_version version delay_upgrade
38-
39-
remote_version="$1"
40-
version="$2"
41-
delay_upgrade="${SDKMAN_DIR}/var/delay_upgrade"
42-
43-
if [[ -n "$(find "$delay_upgrade" -mtime +1)" && "$remote_version" != "$version" ]]; then
44-
echo ""
45-
echo ""
46-
__sdkman_echo_yellow "ATTENTION: A new version of SDKMAN is available..."
47-
echo ""
48-
__sdkman_echo_no_colour "The current version is $remote_version, but you have $version."
49-
echo ""
50-
51-
if [[ "$sdkman_auto_answer" == false ]]; then
52-
__sdkman_echo_confirm "Would you like to upgrade now? (Y/n): "
53-
read upgrade
54-
fi
55-
56-
if [[ -z "$upgrade" ]]; then
57-
upgrade="Y"
58-
fi
59-
60-
if [[ "$upgrade" == "Y" || "$upgrade" == "y" ]]; then
61-
__sdk_selfupdate "force"
62-
unset upgrade
63-
else
64-
__sdkman_echo_no_colour "Not upgrading today..."
65-
fi
66-
67-
touch "$delay_upgrade"
68-
fi
69-
}

src/test/groovy/sdkman/specs/SelfupdateSpec.groovy

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,4 @@ class SelfupdateSpec extends SdkmanEnvSpecification {
5757
"false" | { it.contains("Invalid command: selfupdate") }
5858
"true" | { it.contains("No update available at this time.") }
5959
}
60-
61-
def "should perform an autoupdate when the selfupdate feature is toggled on and autoupdate is enabled"() {
62-
given:
63-
new File("$sdkmanDotDirectory/var/delay_upgrade").with {
64-
parentFile.mkdirs()
65-
createNewFile()
66-
lastModified = Instant.now().minus(2, DAYS).toEpochMilli()
67-
}
68-
69-
bash = sdkmanBashEnvBuilder
70-
.withSdkmanVersion("4.0.0")
71-
.withConfiguration("sdkman_selfupdate_feature", selfupdateFeature)
72-
.withConfiguration("sdkman_auto_update", autoUpdateEnabled)
73-
.withConfiguration("sdkman_auto_answer", "true")
74-
.build()
75-
76-
bash.start()
77-
bash.execute("source $bootstrapScript")
78-
79-
when:
80-
bash.execute("sdk version")
81-
82-
then:
83-
verifyOutput(bash.output)
84-
85-
where:
86-
selfupdateFeature | autoUpdateEnabled | verifyOutput
87-
"true" | "true" | { it.contains("ATTENTION: A new version of SDKMAN is available...") }
88-
"true" | "false" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") }
89-
"false" | "true" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") }
90-
}
9160
}

src/test/resources/features/self_update.feature

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,75 +14,6 @@ Feature: Self Update
1414
And I see "Updating SDKMAN..."
1515
And I see "Successfully upgraded SDKMAN."
1616

17-
Scenario: Selfupdate when out of date
18-
Given an outdated initialised environment
19-
And the system is bootstrapped
20-
When I enter "sdk selfupdate"
21-
Then I do not see "A new version of SDKMAN is available..."
22-
And I do not see "Would you like to upgrade now? (Y/n)"
23-
And I do not see "Not upgrading today..."
24-
And I see "Updating SDKMAN..."
25-
And I see "Successfully upgraded SDKMAN."
26-
27-
Scenario: Agree to a suggested Selfupdate
28-
Given an outdated initialised environment
29-
And the system is bootstrapped
30-
When I enter "sdk help" and answer "Y"
31-
Then I see "A new version of SDKMAN is available..."
32-
And I see "Would you like to upgrade now? (Y/n)"
33-
And I see "Successfully upgraded SDKMAN."
34-
And I do not see "Not upgrading today..."
35-
36-
Scenario: Do not agree to a suggested Selfupdate
37-
Given an outdated initialised environment
38-
And the system is bootstrapped
39-
When I enter "sdk help" and answer "N"
40-
Then I see "A new version of SDKMAN is available..."
41-
And I see "Would you like to upgrade now? (Y/n)"
42-
And I see "Not upgrading today..."
43-
And I do not see "Successfully upgraded SDKMAN."
44-
45-
Scenario: Automatically Selfupdate
46-
Given an outdated initialised environment
47-
And the configuration file has been primed with "sdkman_auto_answer=true"
48-
And the system is bootstrapped
49-
When I enter "sdk help"
50-
Then I see "A new version of SDKMAN is available..."
51-
And I do not see "Would you like to upgrade now? (Y/n)"
52-
And I do not see "Not upgrading today..."
53-
And I see "Successfully upgraded SDKMAN."
54-
55-
Scenario: Do not automatically Selfupdate
56-
Given an outdated initialised environment
57-
And the configuration file has been primed with "sdkman_auto_answer=false"
58-
And the system is bootstrapped
59-
When I enter "sdk help" and answer "n"
60-
Then I see "A new version of SDKMAN is available..."
61-
And I see "Would you like to upgrade now? (Y/n)"
62-
And I see "Not upgrading today..."
63-
And I do not see "Successfully upgraded SDKMAN."
64-
65-
Scenario: Do not check and prompt for update
66-
Given an outdated initialised environment
67-
And the configuration file has been primed with "sdkman_selfupdate_enable=false"
68-
And the system is bootstrapped
69-
When I enter "sdk help"
70-
Then I do not see "A new version of SDKMAN is available..."
71-
And I do not see "Would you like to upgrade now? (Y/n)"
72-
73-
Scenario: Bother the user with Upgrade message once a day
74-
Given an outdated initialised environment
75-
And the system is bootstrapped
76-
When I enter "sdk help" and answer "N"
77-
Then I see "A new version of SDKMAN is available..."
78-
And I see "Would you like to upgrade now? (Y/n)"
79-
And I see "Not upgrading today..."
80-
And I enter "sdk help"
81-
Then I do not see "A new version of SDKMAN is available..."
82-
And I do not see "Would you like to upgrade now? (Y/n)"
83-
And I do not see "Not upgrading now..."
84-
And I do not see "Successfully upgraded SDKMAN."
85-
8617
Scenario: Selfupdate when not out of date
8718
Given an initialised environment
8819
And the system is bootstrapped

0 commit comments

Comments
 (0)