feat(scoop-config): Allow 'hold_update_until' be set manually#5100
Merged
feat(scoop-config): Allow 'hold_update_until' be set manually#5100
Conversation
Member
Author
|
@r15ch13 This should be what you need, right? 😄 |
a4ee104 to
c117593
Compare
Member
|
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 |
Contributor
Member
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
} |
Member
Checking the user input is also a good idea. But that requires a rework of |
Member
Author
|
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>
Member
Author
|
All done @r15ch13 |
r15ch13
approved these changes
Aug 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Rename
update_untiltohold_update_untiland allow it be set manually in the format such asYYYY/MM/DD,YYYY-MM-DDor any other forms that accepted by [System.DateTime]::Parse()Motivation and Context
scoop (un)hold scoop#5089 (comment)How Has This Been Tested?
Checklist:
developbranch.