Commit 904d0ff95d9058585ff4f87964d27cb15aeb9f43
List commits in Update view
Charles Lehner committed on 3/27/2016, 10:52:21 PMParent: 968d06e32da02d4a712327a84f89a90e040e3bc0
Files changed
index.js | changed |
package.json | changed |
index.js | ||
---|---|---|
@@ -16,8 +16,9 @@ | ||
16 | 16 | var multicb = require('multicb') |
17 | 17 | var schemas = require('ssb-msg-schemas') |
18 | 18 | var Issues = require('ssb-issues') |
19 | 19 | var paramap = require('pull-paramap') |
20 | +var gitPack = require('pull-git-pack') | |
20 | 21 | |
21 | 22 | // render links to git objects and ssb objects |
22 | 23 | var blockRenderer = new marked.Renderer() |
23 | 24 | blockRenderer.urltransform = function (url) { |
@@ -898,26 +899,30 @@ | ||
898 | 899 | return renderRepoPage(repo, branch, cat([ |
899 | 900 | pull.once('<h3>Commits</h3>'), |
900 | 901 | pull( |
901 | 902 | repo.readLog(branch), |
902 | - pull.asyncMap(function (hash, cb) { | |
903 | + paramap(function (hash, cb) { | |
903 | 904 | repo.getCommitParsed(hash, function (err, commit) { |
904 | 905 | 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)) | |
914 | 907 | }) |
915 | - }) | |
908 | + }, 8) | |
916 | 909 | ) |
917 | 910 | ])) |
918 | 911 | } |
919 | 912 | |
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 | + | |
920 | 925 | /* Repo tree */ |
921 | 926 | |
922 | 927 | function revMenu(repo, currentName) { |
923 | 928 | return readOnce(function (cb) { |
@@ -1088,18 +1093,51 @@ | ||
1088 | 1093 | } |
1089 | 1094 | } |
1090 | 1095 | } |
1091 | 1096 | |
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 | + ])) | |
1102 | 1140 | } |
1103 | 1141 | |
1104 | 1142 | function renderObject(obj) { |
1105 | 1143 | return '<section class="collapse">' + |
Built with git-ssb-web