fix: use numstat to filter whitespace-only changes with -W flag#1217
Merged
fix: use numstat to filter whitespace-only changes with -W flag#1217
Conversation
Prevents potential RangeError on large arrays by using item-by-item push instead of spread operator which can overflow the call stack.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1217 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 57 58 +1
Lines 1528 1542 +14
Branches 194 194
=========================================
+ Hits 1528 1542 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Published under $ sf plugins install sf-git-merge-driver@dev-1217 |
|
Shipped in release $ sf plugins install sfdx-git-delta@latest-rc
# Or
$ sf plugins install sfdx-git-delta@v6.32.2💡 Enjoying sfdx-git-delta? |
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.
Explain your changes
Fixes regression introduced in commit 8244258 where the
-W(ignore whitespace) flag incorrectly includes files with only whitespace changes in the delta package.Root cause:
git diff --name-statusignores whitespace flags for file reporting — a file with only whitespace changes still appears asM. The previous implementation (v6.19.0) usedgit diff --numstatwith per-change-type queries, where whitespace flags cause such files to produce0 0stats and--diff-filter=Mnaturally excludes them.Fix: Revert
getDiffLines()from a single--name-status --diff-filter=AMDcall to 3 sequential--numstat --diff-filter=Xcalls (one per change type: A, M, D). Output format (X\tpath) is unchanged — no downstream changes needed.Additional improvement: Replaced all 5
push(...spread)occurrences across the codebase with a stack-safepushAllutility to prevent potentialRangeErroron large arrays.Does this close any currently open issues?
Nop
Any particular element that can be tested locally
Use
-Wflag with two commits where a file has only whitespace changes (e.g., a blank line removed). The file should NOT appear in the generatedpackage.xml: