Skip to content

Commit

Permalink
include title in NAME_FIELDS
Browse files Browse the repository at this point in the history
Also adds support for ovveriding the filter list in `Diffable.sync`.
This is needed for milestones to work correctly. However, it should be tested well to ensure it does not break anything else.
  • Loading branch information
Gramatus committed Sep 15, 2024
1 parent 0511bb7 commit 7609c94
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/mergeDeep.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mergeBy = require('./mergeArrayBy')
const DeploymentConfig = require('./deploymentConfig')

const NAME_FIELDS = ['name', 'username', 'actor_id', 'login', 'type', 'key_prefix']
const NAME_FIELDS = ['name', 'username', 'actor_id', 'login', 'type', 'key_prefix', 'title']
const NAME_USERNAME_PROPERTY = item => NAME_FIELDS.find(prop => Object.prototype.hasOwnProperty.call(item, prop))
const GET_NAME_USERNAME_PROPERTY = item => { if (NAME_USERNAME_PROPERTY(item)) return item[NAME_USERNAME_PROPERTY(item)] }

Expand Down
5 changes: 3 additions & 2 deletions lib/plugins/diffable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ const MergeDeep = require('../mergeDeep')
const NopCommand = require('../nopcommand')
const ignorableFields = ['id', 'node_id', 'default', 'url']
module.exports = class Diffable extends ErrorStash {
constructor (nop, github, repo, entries, log, errors) {
constructor (nop, github, repo, entries, log, errors, filterNameFields) {
super(errors)
this.github = github
this.repo = repo
this.entries = entries
this.log = log
this.nop = nop
this.filterNameFields = filterNameFields ?? MergeDeep.NAME_FIELDS
}

filterEntries () {
Expand Down Expand Up @@ -101,7 +102,7 @@ module.exports = class Diffable extends ErrorStash {
}
}
}
filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !MergeDeep.NAME_FIELDS.includes(key)).length !== 0)
filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !this.filterNameFields.includes(key)).length !== 0)

const changes = []

Expand Down
5 changes: 3 additions & 2 deletions lib/plugins/milestones.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const MergeDeep = require('../mergeDeep')
const Diffable = require('./diffable')

module.exports = class Milestones extends Diffable {
constructor (...args) {
super(...args)
constructor (nop, github, repo, entries, log, errors) {
super(nop, github, repo, entries, log, errors, MergeDeep.NAME_FIELDS.filter(i => i !== 'title'))

if (this.entries) {
this.entries.forEach(milestone => {
Expand Down

0 comments on commit 7609c94

Please sign in to comment.