Skip to content

Commit 46642ce

Browse files
committed
fix: use slug-aware matching in MergeDeep.processArrays for teams
Teams in YAML use slug format (e.g. name: "my-team") while the GitHub API returns display name (e.g. name: "My Team") with a separate slug field. This caused phantom diffs in NOP mode: teams reported as additions + deletions when no actual changes exist. The fix adds slug-aware matching in processArrays addition/deletion filters. When a target item has a slug field, it's compared against the source name (which is the slug in safe-settings convention). This is backward compatible: items without slug (labels, rulesets) continue to match by name as before.
1 parent 254bad3 commit 46642ce

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/mergeDeep.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class MergeDeep {
184184
if (source.length < target.length) {
185185
const dels = target.filter(item => {
186186
if (this.isObjectNotArray(item)) {
187-
return !source.some(sourceItem => GET_NAME_USERNAME_PROPERTY(item) === GET_NAME_USERNAME_PROPERTY(sourceItem))
187+
return !source.some(sourceItem => { const s = GET_NAME_USERNAME_PROPERTY(sourceItem); const t = GET_NAME_USERNAME_PROPERTY(item); if (s === t) return true; if (item.slug && typeof s === "string") return item.slug === s || item.slug === s.toLowerCase(); return false; })
188188
} else {
189189
return !source.includes(item)
190190
}
@@ -222,7 +222,7 @@ class MergeDeep {
222222
// Elements that are not in target are additions
223223
additions[key] = combined.filter(item => {
224224
if (this.isObjectNotArray(item)) {
225-
return !target.some(targetItem => GET_NAME_USERNAME_PROPERTY(item) === GET_NAME_USERNAME_PROPERTY(targetItem))
225+
return !target.some(targetItem => { const s = GET_NAME_USERNAME_PROPERTY(item); const t = GET_NAME_USERNAME_PROPERTY(targetItem); if (s === t) return true; if (targetItem.slug && typeof s === "string") return targetItem.slug === s || targetItem.slug === s.toLowerCase(); return false; })
226226
} else {
227227
return !target.includes(item)
228228
}
@@ -233,7 +233,7 @@ class MergeDeep {
233233
// Elements that not in source are deletions
234234
deletions[key] = combined.filter(item => {
235235
if (this.isObjectNotArray(item)) {
236-
return !source.some(sourceItem => GET_NAME_USERNAME_PROPERTY(item) === GET_NAME_USERNAME_PROPERTY(sourceItem))
236+
return !source.some(sourceItem => { const s = GET_NAME_USERNAME_PROPERTY(sourceItem); const t = GET_NAME_USERNAME_PROPERTY(item); if (s === t) return true; if (item.slug && typeof s === "string") return item.slug === s || item.slug === s.toLowerCase(); return false; })
237237
} else {
238238
return !source.includes(item)
239239
}

0 commit comments

Comments
 (0)