Skip to content

Commit 055a5c6

Browse files
committed
include title in NAME_FIELDS
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.
1 parent c6f5bde commit 055a5c6

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/mergeDeep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const mergeBy = require('./mergeArrayBy')
22
const DeploymentConfig = require('./deploymentConfig')
33

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

lib/plugins/diffable.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ const MergeDeep = require('../mergeDeep')
2424
const NopCommand = require('../nopcommand')
2525
const ignorableFields = ['id', 'node_id', 'default', 'url']
2626
module.exports = class Diffable extends ErrorStash {
27-
constructor (nop, github, repo, entries, log, errors) {
27+
constructor (nop, github, repo, entries, log, errors, filterNameFields) {
2828
super(errors)
2929
this.github = github
3030
this.repo = repo
3131
this.entries = entries
3232
this.log = log
3333
this.nop = nop
34+
this.filterNameFields = filterNameFields ?? MergeDeep.NAME_FIELDS
3435
}
3536

3637
filterEntries () {
@@ -102,7 +103,7 @@ module.exports = class Diffable extends ErrorStash {
102103
}
103104
}
104105
// Delete any diffable that now only has name and no other attributes
105-
filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !MergeDeep.NAME_FIELDS.includes(key)).length !== 0)
106+
filteredEntries = filteredEntries.filter(entry => Object.keys(entry).filter(key => !this.filterNameFields.includes(key)).length !== 0)
106107

107108
const changes = []
108109

lib/plugins/milestones.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
const MergeDeep = require('../mergeDeep')
12
const Diffable = require('./diffable')
23

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

78
if (this.entries) {
89
this.entries.forEach(milestone => {

0 commit comments

Comments
 (0)