Files: c51a7c32602d5b5501312e9ad0344b4a93fdd8f8 / lib / forks.js
1599 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 | process.stderr.write('Loading forks...\r') |
28 | var id = u.repoId(u.getRemoteUrl(argv._[0])) || u.getDefaultRemote() |
29 | if (!id) |
30 | err(1, 'unable to find git-ssb repo') |
31 | |
32 | u.getSbot(argv, function (err, sbot) { |
33 | if (err) throw err |
34 | sbot.whoami(function (err, feed) { |
35 | if (err) throw err |
36 | sbot.get(id, function (err, msg) { |
37 | if (err) throw err |
38 | pull( |
39 | getForks(sbot, {key: id, value: msg, indent: ''}), |
40 | paramap(function (msg, cb) { |
41 | var done = multicb({pluck: 1, spread: true}) |
42 | getAbout(sbot, feed.id, msg.value.author, done()) |
43 | getAbout(sbot, feed.id, msg.key, done()) |
44 | done(function (err, authorAbout, repoAbout) { |
45 | if (err) return cb(err) |
46 | cb(null, msg.indent + '- ' + |
47 | 'ssb://' + msg.key + ' ' + |
48 | '@' + authorAbout.name + ' ' + |
49 | (repoAbout.name||'')) |
50 | }) |
51 | }, 8), |
52 | pull.log(sbot.close) |
53 | ) |
54 | }) |
55 | }) |
56 | }) |
57 | } |
58 |
Built with git-ssb-web