Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scoop-(un)hold): Support scoop (un)hold scoop #5089

Merged
merged 34 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
66296dc
feat(scoop-config): Add new configuration of `SCOOP_HOLD`
yi-Xu-0100 Aug 6, 2022
d740651
perf(scoop-update): Separate `update_bucket` from `update_scoop`
yi-Xu-0100 Aug 7, 2022
2e54195
perf(scoop-(un)hold): remove big overarching if-statement
yi-Xu-0100 Aug 7, 2022
0cb48c2
perf(scoop-config): use `SCOOP_HOLD_DAYS` instead of `SCOOP_HOLD`
yi-Xu-0100 Aug 8, 2022
3db0991
perf(scoop-config): Update forward Compatible code
yi-Xu-0100 Aug 8, 2022
5359483
Update libexec/scoop-config.ps1
yi-Xu-0100 Aug 8, 2022
6b50203
Update libexec/scoop-hold.ps1
yi-Xu-0100 Aug 8, 2022
68ce6aa
Update libexec/scoop-unhold.ps1
yi-Xu-0100 Aug 8, 2022
5f51ba8
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 8, 2022
7f63df2
perf(scoop-update): Update last_scoop_update
yi-Xu-0100 Aug 8, 2022
5b2b622
docs(changelog): update changelog to add feature
yi-Xu-0100 Aug 8, 2022
99e8af4
fix(changelog): fix changelog typo
yi-Xu-0100 Aug 8, 2022
9e6090a
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 8, 2022
01cb22c
Update libexec/scoop-config.ps1
yi-Xu-0100 Aug 8, 2022
36c39dd
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 8, 2022
9d434ea
refactor: Use `lastUpdate` instead of `lastupdate`
yi-Xu-0100 Aug 8, 2022
b7b2d1e
fix(install): make config lastUpdate silent
yi-Xu-0100 Aug 8, 2022
23a8c45
refactor(scoop-update): Remove `SCOOP_HOLD`
yi-Xu-0100 Aug 8, 2022
6fea71b
fix: update changelog
yi-Xu-0100 Aug 8, 2022
d271913
Update lib/core.ps1
yi-Xu-0100 Aug 9, 2022
5b69df4
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
d555b05
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
76eb3af
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
d0968cc
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
d3cae39
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
d9a7403
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
8bf4193
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
c500a5b
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
ab5d102
Update libexec/scoop-update.ps1
yi-Xu-0100 Aug 9, 2022
ce151cb
perf(scoop-update): Handle the judgment in try-catch
yi-Xu-0100 Aug 9, 2022
c28e207
fix(scoop-update): Remove 'update_until' when update scoop itself
yi-Xu-0100 Aug 9, 2022
4a2498d
Update lib/core.ps1
yi-Xu-0100 Aug 9, 2022
7b3f87b
Merge branch 'develop' into develop
yi-Xu-0100 Aug 10, 2022
2fa93d1
docs(CHANGELOG): Update changelog
yi-Xu-0100 Aug 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libexec/scoop-config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
# Could be used for testing specific functionalities before released into all users.
# If you want to receive updates earlier to test new functionalities use develop (see: 'https://github.com/ScoopInstaller/Scoop/issues/2939')
#
# SCOOP_HOLD_DAYS: 1
# Allow to disable Scoop itself updates for 'SCOOP_HOLD_DAYS' days.
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
# This configuration havs the same effect with 'scoop (un)hold scoop'.
#
# proxy: [username:password@]host:port
# By default, Scoop will use the proxy settings from Internet Options, but with anonymous authentication.
#
Expand Down
5 changes: 5 additions & 0 deletions libexec/scoop-hold.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ if ($global -and !(is_admin)) {
$apps | ForEach-Object {
$app = $_

if ($app -eq 'scoop') {
set_config 'SCOOP_HOLD_DAYS' 1 | Out-Null
success "$app is now held and can not be updated for one day."
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
return
}
if (!(installed $app $global)) {
if ($global) {
error "'$app' is not installed globally."
Expand Down
5 changes: 5 additions & 0 deletions libexec/scoop-unhold.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ if ($global -and !(is_admin)) {
$apps | ForEach-Object {
$app = $_

if ($app -eq 'scoop') {
set_config 'SCOOP_HOLD_DAYS' $null | Out-Null
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
success "$app is no longer held and can be updated again."
return
}
if (!(installed $app $global)) {
if ($global) {
error "'$app' is not installed globally."
Expand Down
24 changes: 20 additions & 4 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ if(($PSVersionTable.PSVersion.Major) -lt 5) {

yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
function update_scoop() {
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
# check for git
if(!(Test-CommandAvailable git)) { abort "Scoop uses Git to update itself. Run 'scoop install git' and try again." }
if (!(Test-CommandAvailable git)) { abort "Scoop uses Git to update itself. Run 'scoop install git' and try again." }

$SCOOP_HOLD_DAYS = get_config 'SCOOP_HOLD_DAYS' 0
if (((New-TimeSpan (scoop config lastUpdate)).Days) -lt $SCOOP_HOLD_DAYS) {
warn "'SCOOP_HOLD_DAYS' has been setting to '$SCOOP_HOLD_DAYS' and skip updating Scoop..."
warn "If you want to update Scoop itself, use 'scoop unhold scoop' to enable it."
warn "If you want to change 'SCOOP_HOLD_DAYS', use 'scoop config SCOOP_HOLD_DAYS <days>' to set value."
return
}
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved

Write-Host "Updating Scoop..."
$last_update = $(last_scoop_update)
Expand Down Expand Up @@ -135,6 +143,11 @@ function update_scoop() {
# }

shim "$currentdir\bin\scoop.ps1" $false
}

function update_bucket() {
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
# check for git
if(!(Test-CommandAvailable git)) { abort "Scoop uses Git to update main bucket and others. Run 'scoop install git' and try again." }

foreach ($bucket in Get-LocalBucket) {
Write-Host "Updating '$bucket' bucket..."
Expand Down Expand Up @@ -165,9 +178,6 @@ function update_scoop() {
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"
}
}

set_config lastupdate ([System.DateTime]::Now.ToString('o')) | Out-Null
success 'Scoop was updated successfully!'
}

function update($app, $global, $quiet = $false, $independent, $suggested, $use_cache = $true, $check_hash = $true) {
Expand Down Expand Up @@ -305,6 +315,9 @@ if (-not ($apps -or $all)) {
exit 1
}
update_scoop
update_bucket
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
set_config lastupdate ([System.DateTime]::Now.ToString('o')) | Out-Null
success 'Scoop was updated successfully!'
} else {
if ($global -and !(is_admin)) {
'ERROR: You need admin rights to update global apps.'; exit 1
Expand All @@ -317,6 +330,9 @@ if (-not ($apps -or $all)) {

if ($updateScoop) {
update_scoop
update_bucket
yi-Xu-0100 marked this conversation as resolved.
Show resolved Hide resolved
set_config lastupdate ([System.DateTime]::Now.ToString('o')) | Out-Null
success 'Scoop was updated successfully!'
}

if ($apps_param -eq '*' -or $all) {
Expand Down