git ssb

30+

cel / git-ssb-web



Commit 904d0ff95d9058585ff4f87964d27cb15aeb9f43

List commits in Update view

Charles Lehner committed on 3/27/2016, 10:52:21 PM
Parent: 968d06e32da02d4a712327a84f89a90e040e3bc0

Files changed

index.jschanged
package.jsonchanged
index.jsView
@@ -16,8 +16,9 @@
1616 var multicb = require('multicb')
1717 var schemas = require('ssb-msg-schemas')
1818 var Issues = require('ssb-issues')
1919 var paramap = require('pull-paramap')
20+var gitPack = require('pull-git-pack')
2021
2122 // render links to git objects and ssb objects
2223 var blockRenderer = new marked.Renderer()
2324 blockRenderer.urltransform = function (url) {
@@ -898,26 +899,30 @@
898899 return renderRepoPage(repo, branch, cat([
899900 pull.once('<h3>Commits</h3>'),
900901 pull(
901902 repo.readLog(branch),
902- pull.asyncMap(function (hash, cb) {
903+ paramap(function (hash, cb) {
903904 repo.getCommitParsed(hash, function (err, commit) {
904905 if (err) return cb(err)
905- var commitPath = [repo.id, 'commit', commit.id]
906- var treePath = [repo.id, 'tree', commit.id]
907- cb(null, '<section class="collapse">' +
908- '<strong>' + link(commitPath, commit.title) + '</strong><br>' +
909- '<code>' + commit.id + '</code> ' +
910- link(treePath, 'Tree') + '<br>' +
911- (commit.separateAuthor ? escapeHTML(commit.author.name) + ' authored on ' + commit.author.date.toLocaleString() + '<br>' : '') +
912- escapeHTML(commit.committer.name) + ' committed on ' + commit.committer.date.toLocaleString() +
913- '</section>')
906+ cb(null, renderCommit(repo, commit))
914907 })
915- })
908+ }, 8)
916909 )
917910 ]))
918911 }
919912
913+ function renderCommit(repo, commit) {
914+ var commitPath = [repo.id, 'commit', commit.id]
915+ var treePath = [repo.id, 'tree', commit.id]
916+ return '<section class="collapse">' +
917+ '<strong>' + link(commitPath, commit.title) + '</strong><br>' +
918+ '<code>' + commit.id + '</code> ' +
919+ link(treePath, 'Tree') + '<br>' +
920+ (commit.separateAuthor ? escapeHTML(commit.author.name) + ' authored on ' + commit.author.date.toLocaleString() + '<br>' : '') +
921+ escapeHTML(commit.committer.name) + ' committed on ' + commit.committer.date.toLocaleString() +
922+ '</section>'
923+}
924+
920925 /* Repo tree */
921926
922927 function revMenu(repo, currentName) {
923928 return readOnce(function (cb) {
@@ -1088,18 +1093,51 @@
10881093 }
10891094 }
10901095 }
10911096
1092- return renderRepoPage(repo, null, pull.once(
1093- (raw ? '<a href="?" class="raw-link header-align">Info</a>' :
1094- '<a href="?raw" class="raw-link header-align">Data</a>') +
1095- '<h3>Update</h3>' +
1096- (raw ? '<section class="collapse">' + json(msg) + '</section>' :
1097- renderRepoUpdate(repo, {key: id, value: msg}, true) +
1098- (msg.content.objects ? '<h3>Objects</h3>' +
1099- objsArr(msg.content.objects).map(renderObject).join('\n') : '') +
1100- (msg.content.packs ? '<h3>Packs</h3>' +
1101- msg.content.packs.map(renderPack).join('\n') : ''))))
1097+ return renderRepoPage(repo, null,
1098+ raw ? pull.once(
1099+ '<a href="?" class="raw-link header-align">Info</a>' +
1100+ '<h3>Update</h3>' +
1101+ '<section class="collapse">' + json(msg) + '</section>')
1102+ : cat([
1103+ pull.once(
1104+ '<a href="?raw" class="raw-link header-align">Data</a>' +
1105+ '<h3>Update</h3>' +
1106+ renderRepoUpdate(repo, {key: id, value: msg}, true) +
1107+ (msg.content.objects ? '<h3>Objects</h3>' +
1108+ objsArr(msg.content.objects).map(renderObject).join('\n') : '') +
1109+ (msg.content.packs ? '<h3>Packs</h3>' +
1110+ msg.content.packs.map(renderPack).join('\n') : '')),
1111+ cat(!msg.content.packs ? [] : [
1112+ pull.once('<h3>Commits</h3>'),
1113+ pull(
1114+ pull.values(msg.content.packs),
1115+ paramap(function (pack, cb) {
1116+ var key = pack.pack.link
1117+ ssb.blobs.want(key, function (err, got) {
1118+ if (err) cb(err)
1119+ else if (!got) cb(null, pull.once('Missing blob ' + key))
1120+ else cb(null, ssb.blobs.get(key))
1121+ })
1122+ }, 8),
1123+ pull.map(function (readPack, cb) {
1124+ return gitPack.decode({}, repo, cb, readPack)
1125+ }),
1126+ pull.flatten(),
1127+ paramap(function (obj, cb) {
1128+ if (obj.type == 'commit')
1129+ Repo.getCommitParsed(obj, cb)
1130+ else
1131+ pull(obj.read, pull.drain(null, cb))
1132+ }, 8),
1133+ pull.filter(),
1134+ pull.map(function (commit) {
1135+ return renderCommit(repo, commit)
1136+ })
1137+ )
1138+ ])
1139+ ]))
11021140 }
11031141
11041142 function renderObject(obj) {
11051143 return '<section class="collapse">' +
package.jsonView
@@ -6,8 +6,9 @@
66 "dependencies": {
77 "asyncmemo": "^0.1.0",
88 "multicb": "^1.2.1",
99 "pull-cat": "^1.1.8",
10+ "pull-git-pack": "^0.1.2",
1011 "pull-git-repo": "^0.2.5",
1112 "pull-paramap": "^1.1.2",
1213 "pull-stream": "^3.1.0",
1314 "ssb-client": "^3.0.1",

Built with git-ssb-web