From b9dbfb3db9ee72c3b45f688786427105e2785799 Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 14 Mar 2020 22:48:09 -0400 Subject: git: handle messsages linking to git blobs not present in that specific message Search parent commits for the linked git object --- lib/serve.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/serve.js') diff --git a/lib/serve.js b/lib/serve.js index 653a1e0..4089635 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -2426,6 +2426,7 @@ Serve.prototype.gitCommit = function (rev) { + '?msg=' + encodeURIComponent(msg.key)) + '&commit=' + rev + '&path=' + encodeURIComponent(file.name) + + '&search=1' }, 'created') : file.hash ? ph('a', {href: @@ -2434,6 +2435,7 @@ Serve.prototype.gitCommit = function (rev) { + '?msg=' + encodeURIComponent(msg.key)) + '&commit=' + rev + '&path=' + encodeURIComponent(file.name) + + '&search=1' }, 'changed') : file.mode ? 'mode changed' : JSON.stringify(file)) @@ -2651,6 +2653,24 @@ Serve.prototype.gitBlob = function (rev) { self.respondSink(400) ) + if (self.query.search) { + return self.app.git.getObjectMsg({ + obj: rev, + headMsgId: self.query.msg, + }, function (err, msg) { + if (err && err.name === 'BlobNotFoundError') + return self.askWantBlobs(err.links) + if (err) return pull( + pull.once(u.renderError(err).outerHTML), + self.wrapPage('git blob ' + rev), + self.respondSink(400) + ) + var path = '/git/blob/' + rev + + '?msg=' + encodeURIComponent(msg.key) + return self.redirect(self.app.render.toUrl(path)) + }) + } + self.getMsgDecryptedMaybeOoo(self.query.msg, function (err, msg) { if (err) return pull( pull.once(u.renderError(err).outerHTML), -- cgit v1.2.3