mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-05-19 05:58:43 -04:00
Make selfupdate idempotent.
This commit is contained in:
@@ -160,9 +160,9 @@ function __gvmtool_default_environment_variables {
|
||||
}
|
||||
|
||||
function __gvmtool_check_upgrade_available {
|
||||
UPGRADE_AVAILABLE=""
|
||||
UPGRADE_AVAILABLE="false"
|
||||
UPGRADE_NOTICE=$(echo "${BROADCAST_LIVE}" | grep 'Your version of GVM is out of date!')
|
||||
if [[ -n "${UPGRADE_NOTICE}" && ( "${COMMAND}" != 'selfupdate' ) ]]; then
|
||||
if [[ -n "$UPGRADE_NOTICE" && "$COMMAND" != 'selfupdate' ]]; then
|
||||
UPGRADE_AVAILABLE="true"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ function gvm {
|
||||
|
||||
|
||||
__gvmtool_check_upgrade_available
|
||||
if [[ -n "${UPGRADE_AVAILABLE}" && "$1" != "broadcast" && "$1" != "selfupdate" ]]; then
|
||||
if [[ "${UPGRADE_AVAILABLE}" == "true" && "$1" != "broadcast" && "$1" != "selfupdate" ]]; then
|
||||
echo "${BROADCAST_LIVE}"
|
||||
echo ""
|
||||
else
|
||||
|
||||
@@ -17,8 +17,12 @@
|
||||
#
|
||||
|
||||
function __gvmtool_selfupdate {
|
||||
if [[ "${GVM_ONLINE}" == "false" ]]; then
|
||||
echo "${OFFLINE_MESSAGE}"
|
||||
if [[ "$GVM_AVAILABLE" == "false" ]]; then
|
||||
echo "$OFFLINE_MESSAGE"
|
||||
|
||||
elif [[ "$UPGRADE_AVAILABLE" == "false" ]]; then
|
||||
echo "No update available at this time."
|
||||
|
||||
else
|
||||
curl -s "${GVM_SERVICE}/selfupdate" | bash
|
||||
fi
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
Feature: Self Update
|
||||
|
||||
Background:
|
||||
Given the internet is reachable
|
||||
And an initialised system
|
||||
Given an initialised system
|
||||
And an outdated system
|
||||
And the internet is reachable
|
||||
|
||||
Scenario: Upgrade an outdated installation
|
||||
When I enter "gvm selfupdate"
|
||||
|
||||
@@ -12,6 +12,7 @@ counter = "${(Math.random() * 10000).toInteger()}".padLeft(4, "0")
|
||||
localGroovyCandidate = "/tmp/groovy-core" as File
|
||||
|
||||
gvmVersion = "x.y.z"
|
||||
gvmVersionOutdated = "x.y.y"
|
||||
|
||||
gvmBaseEnv = "/tmp/gvm-$counter"
|
||||
gvmBaseDir = gvmBaseEnv as File
|
||||
|
||||
@@ -40,6 +40,11 @@ Given(~'^an initialised shell$') { ->
|
||||
assert initScript.exists()
|
||||
}
|
||||
|
||||
Given(~'^an outdated system$') {->
|
||||
def initScript = "$gvmDir/bin/gvm-init.sh" as File
|
||||
initScript.text = initScript.text.replace(gvmVersion, gvmVersionOutdated)
|
||||
}
|
||||
|
||||
When(~'^I reinitialise the shell$') { ->
|
||||
def initScript = "$gvmDir/bin/gvm-init.sh" as File
|
||||
assert initScript.exists()
|
||||
|
||||
@@ -69,4 +69,4 @@ And(~'^the staging folder is cleaned up$') {->
|
||||
Given(~'^an empty configuration file$') {->
|
||||
def configFile = "$gvmDir/ext/config" as File
|
||||
configFile.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user