Skip to content

Conversation

@abgox
Copy link

@abgox abgox commented Oct 4, 2025

Description

Fix the filtering condition when retrieving the number of manifests

Motivation and Context

Closes #6508

How Has This Been Tested?

Before
image
After
image

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

Summary by CodeRabbit

  • Bug Fixes

    • Accurate manifest counting in bucket listings by restricting manifests to JSON files, improving bucket totals and reliability.
  • Documentation

    • Changelog updated with an Unreleased Bug Fix entry noting the manifest-filtering correction.

@coderabbitai
Copy link

coderabbitai bot commented Oct 4, 2025

Walkthrough

Updates CHANGELOG.md with an Unreleased bug-fix entry for buckets manifest counting and modifies lib/buckets.ps1 to restrict manifest discovery to JSON files so subdirectories and non-JSON files no longer inflate the Manifests count.

Changes

Cohort / File(s) Summary
Changelog updates
CHANGELOG.md
Added an Unreleased Bug Fixes entry mentioning a fix to bucket manifest counting.
Bucket manifest filtering fix
lib/buckets.ps1
In list_buckets, changed the Get-ChildItem call to use -Path "$path\bucket" with -Recurse -Force -Filter "*.json" -File so Manifests reflects only JSON manifest files.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant U as User
    participant LB as list_buckets (lib/buckets.ps1)
    participant FS as Filesystem

    U->>LB: Request bucket listing
    LB->>FS: Get-ChildItem -Path "$path\\bucket" -Recurse -Force -Filter "*.json" -File
    note right of FS `#d4f1d4`: Returns only JSON manifest files
    FS-->>LB: JSON file list
    LB->>LB: Count/aggregate manifests per bucket
    LB-->>U: Return buckets with corrected Manifests counts
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review focus:
    • lib/buckets.ps1: verify -Path concatenation, correct use of -Filter vs -Include, -File behavior and recursion, and handling of path separators.
    • CHANGELOG.md: confirm entry text and formatting.

Poem

I hopped through folders, nose to the ground,
Found only JSON where answers are found,
No nested dirs to bloat the score,
I counted true manifests, then hopped out the door. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and specifically describes the main change: fixing the filtering condition for manifest retrieval to address incorrect counts.
Linked Issues check ✅ Passed The PR successfully addresses issue #6508 by implementing -Filter for JSON files and -File flag to exclude subdirectories from manifest counts.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the manifest filtering issue: CHANGELOG.md entry for the bug fix and lib/buckets.ps1 logic update are both in-scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 464d77e and 0481348.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-31T01:48:00.222Z
Learnt from: z-Fng
Repo: ScoopInstaller/Scoop PR: 6471
File: CHANGELOG.md:9-9
Timestamp: 2025-08-31T01:48:00.222Z
Learning: The Scoop project's CHANGELOG.md follows a convention of tracking PR numbers only, not issue numbers, according to the maintainer z-Fng.

Applied to files:

  • CHANGELOG.md
🔇 Additional comments (1)
CHANGELOG.md (1)

10-10: Use /pull/ path for PR reference links in changelog entries.

Per the project convention (learnings from z-Fng), CHANGELOG entries should reference PR numbers. While line 10 correctly references PR #6509, the hyperlink points to /issues/6509 instead of /pull/6509. GitHub best practice is to use the correct path for the resource type.

Apply this fix:

-- **buckets:** Fix the filtering condition when retrieving the number of manifests ([#6509](https://github.com/ScoopInstaller/Scoop/issues/6509))
+- **buckets:** Fix the filtering condition when retrieving the number of manifests ([#6509](https://github.com/ScoopInstaller/Scoop/pull/6509))

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/buckets.ps1 (1)

116-117: Good fix! Consider using -Filter for better performance.

The addition of -Include "*.json" and -File correctly addresses the bug where subdirectories were being counted as manifests. This implementation matches the past review suggestion.

However, for better performance and consistency with the existing code at line 53, consider using -Filter instead of -Include:

-        $bucket.Manifests = Get-ChildItem -Path "$path\bucket" -Include "*.json" -File -Force -Recurse -ErrorAction SilentlyContinue |
+        $bucket.Manifests = Get-ChildItem -Path "$path\bucket" -Filter "*.json" -File -Force -Recurse -ErrorAction SilentlyContinue |
                 Measure-Object | Select-Object -ExpandProperty Count

The -Filter parameter is applied by the provider before results are returned, making it more efficient than -Include, which filters after retrieval.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1808151 and d1aaabd.

📒 Files selected for processing (1)
  • lib/buckets.ps1 (1 hunks)

@z-Fng
Copy link
Member

z-Fng commented Nov 5, 2025

However, for better performance and consistency with the existing code at line 53, consider using -Filter instead of -Include.

Small tweak: use -Filter as recommended by CodeRabbit for better performance.

Please update the PR title and resolve merge conflicts as well.

@abgox abgox changed the title Fix the filtering condition when retrieving the number of manifests fix(buckets): fix the filtering condition when retrieving the number of manifests Nov 5, 2025
@z-Fng
Copy link
Member

z-Fng commented Nov 5, 2025

cc: @niheaven Could we merge this? Please take a look when you have time.

niheaven
niheaven previously approved these changes Nov 7, 2025
@niheaven niheaven merged commit 2120c28 into ScoopInstaller:develop Nov 8, 2025
3 checks passed
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.

3 participants