git ssb

39+

cel / git-ssb



Tree: 9879cbb757d4bcde4e81cb784c35900a61a22bd6

Files: 9879cbb757d4bcde4e81cb784c35900a61a22bd6 / lib / pull-requests.js

1770 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
7exports.help = `
8Usage: git ssb prs [--all|--open|--closed] [<repo>]
9
10 List pull requests for a repo
11
12Arguments:
13 repo id, url, or git remote name of the base repo.
14 default: 'origin' or 'ssb'
15Options:
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
21exports.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