Files: a09b2ebd1be805f4383f7b7b114a14678b39d5bb / lib / forks.js
1629 bytesRaw
1 | var pull = require('pull-stream') |
2 | var paramap = require('pull-paramap') |
3 | var multicb = require('multicb') |
4 | var u = require('./util') |
5 | var getAbout = require('ssb-avatar') |
6 | var cat = require('pull-cat') |
7 | |
8 | function getForks(sbot, baseMsg) { |
9 | return cat([ |
10 | pull.once(baseMsg), |
11 | pull( |
12 | sbot.links({ |
13 | dest: baseMsg.key, |
14 | rel: 'upstream', |
15 | values: true |
16 | }), |
17 | pull.map(function (msg) { |
18 | msg.indent = baseMsg.indent + ' ' |
19 | return getForks(sbot, msg) |
20 | }), |
21 | pull.flatten() |
22 | ) |
23 | ]) |
24 | } |
25 | |
26 | module.exports = function repoForks(argv) { |
27 | if (argv.help || argv._.length > 1) return require('./help')('forks') |
28 | |
29 | process.stderr.write('Loading forks...\r') |
30 | var id = u.getRemote(argv._[0]) |
31 | if (!id) throw 'unable to find git-ssb repo' |
32 | |
33 | u.getSbot(argv, function (err, sbot) { |
34 | if (err) throw err |
35 | sbot.whoami(function (err, feed) { |
36 | if (err) throw err |
37 | sbot.get(id, function (err, msg) { |
38 | if (err) throw err |
39 | pull( |
40 | getForks(sbot, {key: id, value: msg, indent: ''}), |
41 | paramap(function (msg, cb) { |
42 | var done = multicb({pluck: 1, spread: true}) |
43 | getAbout(sbot, feed.id, msg.value.author, done()) |
44 | getAbout(sbot, feed.id, msg.key, done()) |
45 | done(function (err, authorAbout, repoAbout) { |
46 | if (err) return cb(err) |
47 | cb(null, msg.indent + '- ' + |
48 | 'ssb://' + msg.key + ' ' + |
49 | '@' + authorAbout.name + ' ' + |
50 | (repoAbout.name||'')) |
51 | }) |
52 | }, 8), |
53 | pull.log(sbot.close) |
54 | ) |
55 | }) |
56 | }) |
57 | }) |
58 | } |
59 |
Built with git-ssb-web