Files: 9879cbb757d4bcde4e81cb784c35900a61a22bd6 / lib / forks.js
1530 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 | |
7 | exports.help = ` |
8 | Usage: git ssb forks [<repo>] |
9 | |
10 | List repos that are forks of the given repo |
11 | |
12 | Arguments: |
13 | repo id, url, or git remote name of the base repo. |
14 | default: 'origin' or 'ssb' |
15 | ` |
16 | |
17 | function indentFork(msg, baseMsg) { |
18 | msg.indent = baseMsg.indent + ' ' |
19 | } |
20 | |
21 | exports.fn = function repoForks(argv) { |
22 | if (argv._.length > 1) return u.help('forks') |
23 | |
24 | process.stderr.write('Loading forks...\r') |
25 | var id = u.getRemote(argv._[0]) |
26 | if (!id) throw 'unable to find git-ssb repo' |
27 | |
28 | u.getSbot(argv, function (err, sbot) { |
29 | if (err) throw err |
30 | sbot.whoami(function (err, feed) { |
31 | if (err) throw err |
32 | sbot.get(id, function (err, msg) { |
33 | if (err) throw err |
34 | pull( |
35 | u.getForks(sbot, {key: id, value: msg, indent: ''}, indentFork), |
36 | paramap(function (msg, cb) { |
37 | var done = multicb({pluck: 1, spread: true}) |
38 | getAbout(sbot, feed.id, msg.value.author, done()) |
39 | getAbout(sbot, feed.id, msg.key, done()) |
40 | done(function (err, authorAbout, repoAbout) { |
41 | if (err) return cb(err) |
42 | cb(null, msg.indent + '- ' + |
43 | 'ssb://' + msg.key + ' ' + |
44 | '@' + authorAbout.name + ' ' + |
45 | (repoAbout.name||'')) |
46 | }) |
47 | }, 8), |
48 | pull.log(sbot.close) |
49 | ) |
50 | }) |
51 | }) |
52 | }) |
53 | } |
54 |
Built with git-ssb-web