Files: 403bed97ce3c8f93b87fa33b014b7f20e5e5670d / lib / pull-requests.js
1770 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 | exports.help = ` |
8 | Usage: git ssb prs [--all|--open|--closed] [<repo>] |
9 | |
10 | List pull requests for a repo |
11 | |
12 | Arguments: |
13 | repo id, url, or git remote name of the base repo. |
14 | default: 'origin' or 'ssb' |
15 | Options: |
16 | --open Show only open pull requests (default) |
17 | --closed Show only closed pull-requests |
18 | --all Show pull requests of all state |
19 | ` |
20 | |
21 | exports.fn = function (argv) { |
22 | if (argv._.length > 1) return u.help('pull-requests') |
23 | |
24 | process.stderr.write('Loading pull requests...\r') |
25 | var headRepo = u.getRemote(argv._[0]) |
26 | if (!headRepo) throw 'unable to find git-ssb head repo' |
27 | |
28 | var open = u.issueStateBool(argv) |
29 | |
30 | u.getSbot(argv, function (err, sbot) { |
31 | if (err) throw err |
32 | sbot.whoami(function (err, feed) { |
33 | if (err) throw err |
34 | pull( |
35 | PRs.init(sbot).list({ |
36 | repo: headRepo, |
37 | open: open |
38 | }), |
39 | paramap(function (pr, cb) { |
40 | getAbout(sbot, feed.id, pr.author, function (err, authorAbout) { |
41 | pr.authorName = authorAbout.name |
42 | cb(err, pr) |
43 | }) |
44 | }, 8), |
45 | pull.map(function (pr) { |
46 | var state = pr.open ? 'open' : 'closed' |
47 | return state + ' ' + pr.id + ' ' + '@' + pr.authorName + '\n' + |
48 | ' ssb://' + pr.headRepo + ':' + pr.headBranch + ' ' + |
49 | '→ ' + pr.baseBranch + '\n' + |
50 | ' ' + u.formatTitle(pr.text, 77) + '\n' |
51 | }), |
52 | pull.drain(function (line) { |
53 | console.log(line) |
54 | }, function (err) { |
55 | if (err) throw err |
56 | process.exit(0) |
57 | }) |
58 | ) |
59 | }) |
60 | }) |
61 | } |
62 | |
63 | |
64 |
Built with git-ssb-web