From 4f819768f2828788b1139b5454abf90dea4cc050 Mon Sep 17 00:00:00 2001 From: cel Date: Wed, 17 Jan 2018 10:21:31 -1000 Subject: Handle git ref links where the commit is not in the message --- lib/render-msg.js | 1 + lib/serve.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'lib') diff --git a/lib/render-msg.js b/lib/render-msg.js index aaf7271..b4ba87a 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -694,6 +694,7 @@ RenderMsg.prototype.gitUpdate = function (cb) { var type = /^refs\/tags/.test(ref) ? 'tag' : 'commit' var path = id && ('/git/' + type + '/' + encodeURIComponent(id) + '?msg=' + encodeURIComponent(self.msg.key)) + + '&search=1' return h('li', ref.replace(/^refs\/(heads|tags)\//, ''), ': ', id ? h('a', {href: self.render.toUrl(path)}, h('code', id)) diff --git a/lib/serve.js b/lib/serve.js index 145777d..2eecd09 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1739,6 +1739,24 @@ Serve.prototype.gitCommit = 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 commit ' + rev), + self.respondSink(400) + ) + var path = '/git/commit/' + rev + + '?msg=' + encodeURIComponent(msg.key) + return self.redirect(self.app.render.toUrl(path)) + }) + } + self.app.git.openObject({ obj: rev, msg: self.query.msg, -- cgit v1.2.3