diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-01-17 10:21:31 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-01-17 10:21:31 -1000 |
commit | 4f819768f2828788b1139b5454abf90dea4cc050 (patch) | |
tree | b74f3a1daa55bba6667d6c8f68039fdfb9619f48 /lib | |
parent | 464d359b34e33b2b561af2ffdfe4f6dd14178862 (diff) | |
download | patchfoo-4f819768f2828788b1139b5454abf90dea4cc050.tar.gz patchfoo-4f819768f2828788b1139b5454abf90dea4cc050.zip |
Handle git ref links where the commit is not in the message
Diffstat (limited to 'lib')
-rw-r--r-- | lib/render-msg.js | 1 | ||||
-rw-r--r-- | lib/serve.js | 18 |
2 files changed, 19 insertions, 0 deletions
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, |