-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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-config): Allow 'hold_update_until' be set manually #5100
Conversation
@r15ch13 This should be what you need, right? 😄 |
a4ee104
to
c117593
Compare
Yes 😄 But there is no need for exception handling if [datetime]$hold_update_until = New-Object DateTime
$a = [System.DateTime]::TryParse($cfg_value, $null, [System.Globalization.DateTimeStyles]::AssumeLocal,
[ref]$hold_update_until) It simply returns True/False |
function Test-ScoopUpdateOnHold() {
$hold_update_until = get_config hold_update_until
if ($null -eq $hold_update_until) {
return $false
}
[datetime]$parsed_date = New-Object DateTime
if([System.DateTime]::TryParse($hold_update_until, $null, [System.Globalization.DateTimeStyles]::AssumeLocal, [ref]$parsed_date)) {
if ((New-TimeSpan $parsed_date).TotalSeconds -lt 0) {
warn "Skipping self-update until $($parsed_date.ToLocalTime())..."
warn "If you want to update Scoop itself immediately, use 'scoop unhold scoop; scoop update'."
return $true
} else {
warn "Self-update is enabled again!"
set_config hold_update_until $null | Out-Null
}
} else {
error "'hold_update_until' has been set in the wrong format and was removed."
error "If you want to disable Scoop self-update for a moment, use 'scoop hold scoop' or 'scoop config hold_update_until <YYYY-MM-DD>/<YYYY/MM/DD>'."
set_config hold_update_until $null | Out-Null
}
return $false
} And then use function update_scoop($show_update_log) {
# snip
if(Test-ScoopUpdateOnHold) {
return
}
# snip
} |
Checking the user input is also a good idea. But that requires a rework of |
Wow, yes, I was trying to use I'll fix the code tomorrow using above code and test it again (maybe it is been tested? 🤣 ) |
Co-authored-by: Richard Kuhnt <r15ch13+git@gmail.com>
All done @r15ch13 |
Description
Rename
update_until
tohold_update_until
and allow it be set manually in the format such asYYYY/MM/DD
,YYYY-MM-DD
or any other forms that accepted by [System.DateTime]::Parse()Motivation and Context
scoop (un)hold scoop
#5089 (comment)How Has This Been Tested?
Checklist:
develop
branch.