Files: a09b2ebd1be805f4383f7b7b114a14678b39d5bb / lib / pull-requests.js
1433 bytesRaw
1 | var pull = require('pull-stream') |
2 | var paramap = require('pull-paramap') |
3 | var u = require('./util') |
4 | var getAbout = require('ssb-avatar') |
5 | var PRs = require('ssb-pull-requests') |
6 | |
7 | module.exports = function (argv) { |
8 | if (argv.help || argv._.length > 1) return require('./help')('pull-requests') |
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