git ssb

39+

cel / git-ssb



Commit e27ec206cca7a423f36fd4404a4d58e34bae6699

Add log command

cel committed on 11/22/2016, 1:43:18 AM
Parent: ce32700bb99534de84bce95069bc5daaff7f3d9d

Files changed

lib/index.txtchanged
lib/log.jsadded
lib/log.txtadded
lib/index.txtView
@@ -6,8 +6,9 @@
66 forks List forks of a repo
77 issues List issues for a repo
88 prs List pull requests for a repo
99 authors List contributors to a repo
10 + log List history of updates to a repo
1011 name Name a repo
1112 pull-request Create a pull-request
1213 web Serve a web server for repos
1314 help Get help about a command
lib/log.jsView
@@ -1,0 +1,63 @@
1 +var pull = require('pull-stream')
2 +var paramap = require('pull-paramap')
3 +var u = require('./util')
4 +var getAbout = require('ssb-avatar')
5 +
6 +module.exports = function (argv) {
7 + var repoId
8 + if (argv.global || argv.g) {
9 + if (argv._.length > 0) return require('./help')('log')
10 + repoId = null
11 + } else {
12 + repoId = u.getRemote(argv._[0])
13 + if (!repoId) throw 'unable to find git-ssb repo'
14 + }
15 +
16 + u.getSbot(argv, function (err, sbot) {
17 + if (err) throw err
18 + sbot.whoami(function (err, feed) {
19 + if (err) throw err
20 + pull(
21 + sbot.links({
22 + dest: repoId,
23 + rel: 'repo',
24 + values: true,
25 + meta: false,
26 + reverse: true,
27 + }),
28 + pull.filter(function (msg) {
29 + var c = msg.value.content
30 + return c.type === 'git-update'
31 + }),
32 + // TODO:
33 + // - sort by timestamp, or causal order?
34 + // - show causal links
35 + paramap(function (msg, cb) {
36 + getAbout(sbot, feed.id, msg.value.author, function (err, about) {
37 + if (err) return cb(err)
38 + msg.authorName = '@' + about.name
39 + cb(err, msg)
40 + })
41 + }, 8),
42 + pull.map(function (msg) {
43 + var c = msg.value.content
44 + var commits = Array.isArray(c.commits) ? c.commits : []
45 + var numMoreCommits = ~~c.commits_more
46 + var date = new Date(msg.value.timestamp)
47 + return '' +
48 +`${msg.key}
49 +${msg.authorName} ${date.toLocaleString()}
50 +${commits.map(commit =>
51 +` + ${String(commit.sha1).substr(0, 8)} ${commit.title||''}
52 +`).join('')}`
53 ++ (c.commits_more ?
54 +` + ${~~c.commits_more} more` : '')
55 + }),
56 + pull.log(function (err) {
57 + if (err) throw err
58 + process.exit(0)
59 + })
60 + )
61 + })
62 + })
63 +}
lib/log.txtView
@@ -1,0 +1,11 @@
1 +Usage: git -p ssb log [--global | <repo>]
2 +
3 + List history of updates to a repo
4 +
5 +Options:
6 + -g --global Show updates to all repos
7 +
8 +Arguments:
9 + repo id, url, or git remote name of the base repo.
10 + default: 'origin' or 'ssb'
11 +

Built with git-ssb-web