git ssb

30+

cel / git-ssb-web



Commit 4ca6939026d55bfcc0f562583e4d275702b652ad

Show list of changed files in commit view

Progress %2s6DPrwQ/RzR22MPYWGxDasdcGwn8hha32kkrtH4+7M=.sha256
Charles Lehner committed on 3/31/2016, 4:22:52 AM
Parent: ba02aa5007c20a431511f04d41c9928886e6a166

Files changed

index.jschanged
package.jsonchanged
index.jsView
@@ -1149,14 +1149,14 @@
11491149
11501150 function serveRepoCommit(repo, rev) {
11511151 return renderRepoPage(repo, null, rev, cat([
11521152 pull.once('<h3>Commit ' + rev + '</h3>'),
1153- readOnce(function (cb) {
1153+ readNext(function (cb) {
11541154 repo.getCommitParsed(rev, function (err, commit) {
11551155 if (err) return cb(err)
11561156 var commitPath = [repo.id, 'commit', commit.id]
11571157 var treePath = [repo.id, 'tree', commit.tree]
1158- cb(null, '<section class="collapse">' +
1158+ cb(null, cat([pull.once('<section class="collapse">' +
11591159 '<strong>' + link(commitPath, commit.title) + '</strong>' +
11601160 (commit.body ? pre(commit.body) : '') +
11611161 '<p>' +
11621162 (commit.separateAuthor ? escapeHTML(commit.author.name) +
@@ -1167,14 +1167,53 @@
11671167 '<p>' + commit.parents.map(function (id) {
11681168 return 'Parent: ' + link([repo.id, 'commit', id], id)
11691169 }).join('<br>') + '</p>' +
11701170 (commit.tree ? 'Tree: ' + link(treePath) : 'No tree') +
1171- '</section>')
1171+ '</section>'),
1172+ renderDiffStat(repo, commit.tree, commit.parents)
1173+ ]))
11721174 })
11731175 })
11741176 ]))
11751177 }
11761178
1179+ /* Diff stat */
1180+
1181+ function renderDiffStat(repo, id, parentIds) {
1182+ if (parentIds.length == 0) parentIds = [null]
1183+ var lastI = parentIds.length
1184+ var oldTree = parentIds[0]
1185+ return cat([
1186+ pull.once('<section><h3>Files changed</h3>'),
1187+ pull(
1188+ repo.diffTrees(parentIds.concat(id), true),
1189+ pull.map(function (item) {
1190+ var filename = escapeHTML(item.path.join('/'))
1191+ var oldId = item.id && item.id[0]
1192+ var newId = item.id && item.id[lastI]
1193+ var oldMode = item.mode && item.mode[0].toString(8)
1194+ var newMode = item.mode && item.mode[lastI].toString(8)
1195+ var action =
1196+ !oldId && newId ? 'new' :
1197+ oldId && !newId ? 'deleted' :
1198+ oldMode != newMode ?
1199+ 'changed mode from ' + oldMode + ' to ' + newMode :
1200+ ''
1201+ var newLink = newId ?
1202+ link([repo.id, 'blob', id].concat(item.path), 'new') : ''
1203+ var oldLink = oldId ?
1204+ link([repo.id, 'blob', oldTree].concat(item.path), 'old') : ''
1205+ var links = [oldLink, newLink]
1206+ var fileLink = newLink || oldLink ? filename :
1207+ link([repo.id, 'blob', id].concat(item.path), filename)
1208+ return [fileLink, action, links.filter(Boolean).join(', ')]
1209+ }),
1210+ table()
1211+ ),
1212+ pull.once('</section>'),
1213+ ])
1214+ }
1215+
11771216 /* An unknown message linking to a repo */
11781217
11791218 function serveRepoSomething(req, repo, id, msg, path) {
11801219 return renderRepoPage(repo, null, null,
package.jsonView
@@ -8,9 +8,9 @@
88 "highlight.js": "^9.2.0",
99 "multicb": "^1.2.1",
1010 "pull-cat": "^1.1.8",
1111 "pull-git-pack": "^0.1.2",
12- "pull-git-repo": "^0.3.1",
12+ "pull-git-repo": "^0.3.2",
1313 "pull-paramap": "^1.1.2",
1414 "pull-stream": "^3.1.0",
1515 "ssb-client": "^3.0.1",
1616 "ssb-config": "^1.1.0",

Built with git-ssb-web