Repository navigation
fix(mergedeep): preserve top-level array diff shapes - #1090
Merged
Merged
Conversation
Adapt PR #1030 to the evolved comparison implementation. Keep array diff buckets consistent across empty and populated targets, retain deletions on early returns, and skip unsafe object keys. Cover exact result shapes and first/subsequent ruleset dry-run reporting. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation and regression coverage address the requested diff-shape and reporting behavior.
Review effort: Lite
Findings: None
What changed in this PR
This pull request normalizes top-level array diff shapes in MergeDeep, improving first-ruleset dry-run and reporting consistency.
Changes:
- Preserve array-shaped additions, modifications, and deletions.
- Handle empty targets, recursive accumulators, and unsafe keys safely.
- Add regression coverage for merge and reporting paths.
| File | Description |
|---|---|
test/unit/lib/settings-results.test.js |
Verifies check-run and PR reporting output. |
test/unit/lib/plugins/rulesets.test.js |
Verifies first-ruleset NOP output. |
test/unit/lib/mergeDeep.test.js |
Covers comparison edge cases and immutability. |
lib/mergeDeep.js |
Implements normalized diff shapes and safe copying. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Comparing a repository's first ruleset against an empty target returns index-keyed additions and omits
deletions, producing inconsistent dry-run JSON and reporting. This adapts the missing behavior from #1030 toyadhav/fix-recent-issues, including the review concern about inconsistent empty change buckets.Changes
additions,modifications, anddeletionsfor top-level array comparisons, including empty-target and no-change paths.deletionsin the empty-target object result, preserve recursive accumulator references, and skip unsafe__proto__/constructorkeys when copying object additions.__arrayproperty on object sources.Existing identity matching, order-insensitive comparison, externally defined overrides, deletion behavior, and
hasChangessemantics are preserved. In particular, an undefined/null target with an empty array still reportshasChanges: true; two empty arrays reportfalse.Validation
Using Node 22.12.0:
npm run test:unit -- --runInBand --silent: 548 passed, 12 skipped across 24 passing and 2 skipped suites.git diff --checkpasses.npm run test:integration -- --runInBand --silent: blocked by the reproduced baseline Probot ESM loading error (Unexpected token 'export'); all 7 suites fail before executing tests.Based on
ee288d36b38484883ca0551457e5a8feee061d43; no wholesale merge frommain-enterprise.