git ssb

16+

Dominic / patchbay



Commit faff49e67cc84e5fa54a14136d98a6126f176499

Fix issue state computation

Charles Lehner committed on 8/2/2016, 12:43:13 AM
Parent: c6fc57f70589db3b77746a523628b797dae2341f

Files changed

modules/git.jschanged
modules/git.jsView
@@ -28,35 +28,23 @@
2828 }
2929
3030 function getIssueState(id, cb) {
3131 pull(
32- sbot_links({dest: id, rel: 'issues', values: true}),
32+ sbot_links({dest: id, rel: 'issues', values: true, reverse: true}),
3333 pull.map(function (msg) {
3434 var issues = msg.value.content.issues
3535 if (!Array.isArray(issues)) return
3636 return issues.filter(function (issue) {
3737 return issue.link === id
38- }).map(function (issue) {
39- return {
40- ts: msg.value.timestamp,
41- open: issue.open,
42- merged: issue.merged,
43- }
4438 })
4539 }),
4640 pull.flatten(),
41+ pull.map(function (issue) {
42+ return issue.merged ? 'merged' : issue.open ? 'open' : 'closed'
43+ }),
44+ pull.take(1),
4745 pull.collect(function (err, updates) {
48- if (err) return cb(err)
49- var open = true, merged = false
50- updates.sort(function (a, b) {
51- return b.ts - a.ts
52- }).forEach(function (update) {
53- if (update.open != null)
54- open = update.open
55- if (update.merged != null)
56- merged = update.merged
57- })
58- cb(null, open ? 'open' : merged ? 'merged' : 'closed')
46+ cb(err, updates && updates[0] || 'open')
5947 })
6048 )
6149 }
6250

Built with git-ssb-web