git ssb

39+

cel / git-ssb



Tree: ce32700bb99534de84bce95069bc5daaff7f3d9d

Files: ce32700bb99534de84bce95069bc5daaff7f3d9d / lib / pull-requests.js

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

Built with git-ssb-web