-
Notifications
You must be signed in to change notification settings - Fork 165
/
Copy pathmilestones.js
47 lines (36 loc) · 1.34 KB
/
milestones.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const MergeDeep = require('../mergeDeep')
const Diffable = require('./diffable')
module.exports = class Milestones extends Diffable {
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 => {
if (milestone.due_on) {
delete milestone.due_on
}
})
}
}
find () {
const options = this.github.issues.listMilestones.endpoint.merge(Object.assign({ per_page: 100, state: 'all' }, this.repo))
return this.github.paginate(options)
}
comparator (existing, attrs) {
return existing.title === attrs.title
}
changed (existing, attrs) {
return existing.description !== attrs.description || existing.state !== attrs.state
}
update (existing, attrs) {
const { owner, repo } = this.repo
return this.github.issues.updateMilestone(Object.assign({ milestone_number: existing.number }, attrs, { owner, repo }))
}
add (attrs) {
const { owner, repo } = this.repo
return this.github.issues.createMilestone(Object.assign({}, attrs, { owner, repo }))
}
remove (existing) {
const { owner, repo } = this.repo
return this.github.issues.deleteMilestone(Object.assign({ milestone_number: existing.number }, { owner, repo }))
}
}