git ssb

39+

cel / git-ssb



Tree: d4db2a8da13d8f78996e6913763056d5dd83a8a6

Files: d4db2a8da13d8f78996e6913763056d5dd83a8a6 / lib / pull-requests.js

1395 bytesRaw
1var pull = require('pull-stream')
2var paramap = require('pull-paramap')
3var u = require('./util')
4var getAbout = require('ssb-avatar')
5var PRs = require('ssb-pull-requests')
6
7module.exports = function (argv) {
8 process.stderr.write('Loading pull requests...\r')
9 var headRepo = u.repoId(u.getRemoteUrl(argv._[0])) || u.getDefaultRemote()
10 if (!headRepo)
11 err(1, 'unable to find git-ssb head repo')
12
13 var open = u.issueStateBool(argv)
14
15 u.getSbot(argv, function (err, sbot) {
16 if (err) throw err
17 sbot.whoami(function (err, feed) {
18 if (err) throw err
19 pull(
20 PRs.init(sbot).list({
21 repo: headRepo,
22 open: open
23 }),
24 paramap(function (pr, cb) {
25 getAbout(sbot, feed.id, pr.author, function (err, authorAbout) {
26 pr.authorName = authorAbout.name
27 cb(err, pr)
28 })
29 }, 8),
30 pull.map(function (pr) {
31 var state = pr.open ? 'open' : 'closed'
32 return state + ' ' + pr.id + ' ' + '@' + pr.authorName + '\n' +
33 ' ssb://' + pr.headRepo + ':' + pr.headBranch + ' ' +
34 '→ ' + pr.baseBranch + '\n' +
35 ' ' + u.formatTitle(pr.text, 77) + '\n'
36 }),
37 pull.drain(function (line) {
38 console.log(line)
39 }, function (err) {
40 if (err) throw err
41 process.exit(0)
42 })
43 )
44 })
45 })
46}
47
48
49

Built with git-ssb-web