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

fix(bucket): Return empty list correctly in Get-LocalBucket #4885

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

lewis-yeung
Copy link
Contributor

Description

  1. Return a zero-length list instead of $null in Get-LocalBucket.

  2. Adjust the output message for scoop alias list when there is no alias found.

  3. Adjust the output message for scoop cache show when there is no cache found.

Motivation and Context

  1. I ran into an error when I removed all buckets and was trying to add them back using URLs of mirrors, which means running scoop bucket list when there is nothing in $SCOOP\buckets:

    Get-Item: <path_to_scoop>\apps\scoop\current\lib\buckets.ps1:134:32
    Line |
     134 |              $bucket.Updated = (Get-Item "$path\bucket").LastWriteTime
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~
         | Cannot find path '<path_to_scoop>\buckets\main\bucket' because it does not exist.
    

    The Get-LocalBucket returns $null in this case, so Find-BucketDirectory gets the default value main for $Name:

    Scoop/lib/buckets.ps1

    Lines 126 to 128 in e6d0371

    Get-LocalBucket | ForEach-Object {
    $bucket = [Ordered]@{ Name = $_ }
    $path = Find-BucketDirectory $_ -Root

    Scoop/lib/buckets.ps1

    Lines 13 to 14 in e6d0371

    param(
    [string] $Name = 'main',

    To fix this, we should use a zero-length list instead and give a tip of adding the default main bucket.

  2. No additional description.

  3. scoop cache show shows the following message when there is no cache found:

    Total: 0 files,  B
    

    I think it's better to change it to something like this:

    No cache found.
    

How Has This Been Tested?

Just run as usual:

scoop bucket list
scoop alias list
scoop cache show

Checklist:

libexec/scoop-cache.ps1 Outdated Show resolved Hide resolved
libexec/scoop-alias.ps1 Outdated Show resolved Hide resolved
lib/buckets.ps1 Outdated Show resolved Hide resolved
@lewis-yeung
Copy link
Contributor Author

@rashil2000 Changed and re-pushed. Please take a look. Thanks for your patience.

rashil2000
rashil2000 previously approved these changes Apr 25, 2022
lib/buckets.ps1 Outdated Show resolved Hide resolved
libexec/scoop-cache.ps1 Outdated Show resolved Hide resolved
lib/buckets.ps1 Outdated Show resolved Hide resolved
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
Co-authored-by: Rashil Gandhi <rashil2000@gmail.com>
@niheaven niheaven merged commit 22365c2 into ScoopInstaller:develop Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants