Skip to content

fix: support nested folders for all kind of handlers#1239

Merged
scolladon merged 12 commits intomainfrom
fix/contained-decomposed-nested-folder
Mar 6, 2026
Merged

fix: support nested folders for all kind of handlers#1239
scolladon merged 12 commits intomainfrom
fix/contained-decomposed-nested-folder

Conversation

@scolladon
Copy link
Owner

@scolladon scolladon commented Mar 5, 2026

Explain your changes

Problem

  1. ContainedDecomposedHandler._setholderFolder() used pathAfterType[0] to find the PermissionSet directory, assuming it was immediately after the type directory (permissionsets/). This fails for nested folders like permissionsets/marketing/Admin/fieldPermissions/... where the intermediate folder name (marketing) was used instead of the actual PS name (Admin).

  2. MetadataBoundaryResolver.scanAndCreateElement() walked UP directory by directory calling listDirAtRevision (one git ls-tree subprocess per level) with no caching in GitAdapter. For ~25 depth-3+ files across ~4 type directories, this generated ~20-40 subprocess calls, adding ~2.7s overhead.

Fix

  1. ContainedDecomposedHandler: Compute the PS directory position from the file path's end using named offset constants (PS_DIR_OFFSET_IN_SUBDIR = 3, PS_DIR_OFFSET_FLAT = 2), supporting arbitrary nesting depth. Uses componentName === parentFolder to distinguish flat files from files in child type subdirectories.

  2. MetadataBoundaryResolver: Replace directory walk-up loop with getFilesPath(typeDir, revision) which uses git ls-tree -r (recursive) with GitAdapter's hierarchical cache. ONE git call per type directory instead of N per component. Removed redundant MAX_HIERARCHY_DEPTH guard (loop already terminates at '.'). E2E time reduced from ~26.6s to ~24.3s.


Does this close any currently open issues?

  • Jest tests added to cover the fix.
  • NUT tests added to cover the fix.
  • E2E tests added to cover the fix.

Any particular element that can be tested locally

Test with a decomposed PermissionSet project where the PermissionSet directory is nested inside intermediate folders:

force-app/main/default/permissionsets/marketing/Admin/fieldPermissions/Account.MyField__c.fieldPermission-meta.xml

Verify that package.xml contains PermissionSet: Admin (not PermissionSet: marketing).

Any other comments

  • 100% coverage on all modified files
  • Bot metadata (UNSAFE_EXTENSION suffix) now resolves correctly via direct suffix filtering in getFilesPath, bypassing the findComponentName/metadataRepo.get() limitation
  • Fallback walk-up path retained for edge cases where type directory is not in the path

ContainedDecomposedHandler._setholderFolder() used pathAfterType[0] to
find the PermissionSet directory, assuming it was immediately after the
type directory. This fails for nested folders like
permissionsets/marketing/Admin/fieldPermissions/... where the
intermediate folder name was used instead of the actual PS name.

Fix: compute the PS directory position from the file path's end using
named offset constants, supporting arbitrary nesting depth.
@scolladon scolladon requested a review from mehdicherf as a code owner March 5, 2026 14:03
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (aad4d50) to head (b591526).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1239   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           58        58           
  Lines         1574      1603   +29     
  Branches       204       213    +9     
=========================================
+ Hits          1574      1603   +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@scolladon scolladon force-pushed the fix/contained-decomposed-nested-folder branch from 268b809 to 9f1295d Compare March 5, 2026 14:40
Add tiered resolution strategy to handle intermediate organizational
folders between type directories and components (e.g.,
permissionsets/marketing/Admin/...). The resolver now: (1) returns
fromPath directly for flat paths, (2) skips scanning for empty-suffix
types, (3) extracts component names from depth-2 file names without
git I/O, and (4) bounds deeper scans to the type directory level.

Also fixes BotHandler to use parentFolder instead of pathAfterType[0]
for correct nested folder support.
Return fromPath directly when pathAfterType.length === 2: folder
always matches the component at this depth, so scanning via git
ls-tree is unnecessary.
Use pathExists (git cat-file -t) to probe for meta files directly
instead of listing directories (git ls-tree) and searching for matches.
Checks both inside and beside component directory placements.
those are catched at push
…taBoundaryResolver

Use getFilesPath (git ls-tree -r) with hierarchical cache instead of
walking up directories one level at a time with listDirAtRevision.
This reduces subprocess calls from ~N per component to 1 per type
directory, bringing E2E from ~26.6s to ~24.3s.
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Published under dev-1239 npm channel.

$ sf plugins install sfdx-git-delta@dev-1239

@scolladon scolladon changed the title fix: support nested folders in decomposed PermissionSet path resolution fix: support nested folders for all kind of handlers Mar 6, 2026
@scolladon scolladon merged commit 2168ad0 into main Mar 6, 2026
24 checks passed
@scolladon scolladon deleted the fix/contained-decomposed-nested-folder branch March 6, 2026 09:10
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Shipped in release v6.33.1.
Version v6.33.1 will be assigned to the latest npm channel soon
Install it using either v6.33.1 or the latest-rc npm channel

$ sf plugins install sfdx-git-delta@latest-rc
# Or
$ sf plugins install sfdx-git-delta@v6.33.1

💡 Enjoying sfdx-git-delta?
Your contribution helps us provide fast support 🚀 and high quality features 🔥
Become a sponsor 💙
Happy incremental deployment!

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.

1 participant