Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: array comparison breaks if using the environments plugin #682

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/mergeDeep.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,4 @@ class MergeDeep {
}
}
MergeDeep.NAME_FIELDS = NAME_FIELDS
MergeDeep.NAME_FIELDS = NAME_FIELDS
module.exports = MergeDeep
3 changes: 2 additions & 1 deletion lib/plugins/diffable.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ module.exports = class Diffable extends ErrorStash {
}
}

// Filter out all empty entries (usually from repo override)
// Remove any null or undefined values from the diffables (usually comes from repo override)
for (const entry of filteredEntries) {
for (const key of Object.keys(entry)) {
if (entry[key] === null || entry[key] === undefined) {
delete entry[key]
}
}
}
// Delete any diffable that now only has name and no other attributes
filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !MergeDeep.NAME_FIELDS.includes(key)).length !== 0)

const changes = []
Expand Down
8 changes: 2 additions & 6 deletions lib/plugins/environments.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ module.exports = class Environments extends Diffable {
}
})
}

// Remove 'name' from filtering list so Environments with only a name defined are processed.
MergeDeep.NAME_FIELDS.splice(MergeDeep.NAME_FIELDS.indexOf('name'), 1)

}

async find() {
Expand Down Expand Up @@ -296,15 +292,15 @@ module.exports = class Environments extends Diffable {
let filteredEntries = this.filterEntries()
return this.find().then(existingRecords => {

// Filter out all empty entries (usually from repo override)
// Remove any null or undefined values from the diffables (usually comes from repo override)
for (const entry of filteredEntries) {
for (const key of Object.keys(entry)) {
if (entry[key] === null || entry[key] === undefined) {
delete entry[key]
}
}
}
filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !MergeDeep.NAME_FIELDS.includes(key)).length !== 0)
// For environments, we want to keep the entries with only name defined.

const changes = []

Expand Down
Loading