@@ -54,16 +54,28 @@ if(($PSVersionTable.PSVersion.Major) -lt 5) {
5454 Write-Output " Upgrade PowerShell: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows"
5555 break
5656}
57+ $show_update_log = get_config ' show_update_log' $true
5758
58- function update_scoop () {
59+ function update_scoop ($show_update_log ) {
5960 # check for git
60- if (! (Test-CommandAvailable git)) { abort " Scoop uses Git to update itself. Run 'scoop install git' and try again." }
61+ if (! (Test-CommandAvailable git)) { abort " Scoop uses Git to update itself. Run 'scoop install git' and try again." }
62+
63+ try {
64+ $now = [System.DateTime ]::Now.ToString(' o' )
65+ $update_until = [System.DateTime ]::Parse((get_config update_until $now ))
66+ if ((New-TimeSpan $update_until $now ).TotalSeconds -lt 0 ) {
67+ warn " Skipping self-update until $ ( $update_until.ToLocalTime ()) ..."
68+ warn " If you want to update Scoop itself immediately, use 'scoop unhold scoop; scoop update'."
69+ return
70+ }
71+ } catch {
72+ warn " 'update_until' has been set in the wrong format."
73+ warn " If you want to disable Scoop self-update for a moment, use 'scoop hold scoop'."
74+ }
75+
76+ set_config update_until $null | Out-Null
6177
6278 Write-Host " Updating Scoop..."
63- $last_update = $ (last_scoop_update)
64- if ($null -eq $last_update ) {$last_update = [System.DateTime ]::Now}
65- $last_update = $last_update.ToString (' s' )
66- $show_update_log = get_config ' show_update_log' $true
6779 $currentdir = fullpath $ (versiondir ' scoop' ' current' )
6880 if (! (Test-Path " $currentdir \.git" )) {
6981 $newdir = " $currentdir \..\new"
@@ -135,6 +147,11 @@ function update_scoop() {
135147 # }
136148
137149 shim " $currentdir \bin\scoop.ps1" $false
150+ }
151+
152+ function update_bucket ($show_update_log ) {
153+ # check for git
154+ if (! (Test-CommandAvailable git)) { abort " Scoop uses Git to update main bucket and others. Run 'scoop install git' and try again." }
138155
139156 foreach ($bucket in Get-LocalBucket ) {
140157 Write-Host " Updating '$bucket ' bucket..."
@@ -165,9 +182,6 @@ function update_scoop() {
165182 git - C " $bucketLoc " -- no- pager log -- no- decorate -- grep= ' ^(chore)' -- invert- grep -- format= ' tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset' " $previousCommit ..HEAD"
166183 }
167184 }
168-
169- set_config lastupdate ([System.DateTime ]::Now.ToString(' o' )) | Out-Null
170- success ' Scoop was updated successfully!'
171185}
172186
173187function update ($app , $global , $quiet = $false , $independent , $suggested , $use_cache = $true , $check_hash = $true ) {
@@ -304,7 +318,10 @@ if (-not ($apps -or $all)) {
304318 error ' scoop update: --no-cache is invalid when <app> is not specified.'
305319 exit 1
306320 }
307- update_scoop
321+ update_scoop $show_update_log
322+ update_bucket $show_update_log
323+ set_config lastUpdate ([System.DateTime ]::Now.ToString(' o' )) | Out-Null
324+ success ' Scoop was updated successfully!'
308325} else {
309326 if ($global -and ! (is_admin)) {
310327 ' ERROR: You need admin rights to update global apps.' ; exit 1
@@ -316,7 +333,10 @@ if (-not ($apps -or $all)) {
316333 $apps_param = $apps
317334
318335 if ($updateScoop ) {
319- update_scoop
336+ update_scoop $show_update_log
337+ update_bucket $show_update_log
338+ set_config lastUpdate ([System.DateTime ]::Now.ToString(' o' )) | Out-Null
339+ success ' Scoop was updated successfully!'
320340 }
321341
322342 if ($apps_param -eq ' *' -or $all ) {
0 commit comments