diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-08-30 15:02:46 -0700 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-08-30 15:02:46 -0700 |
commit | 87a69610fde53178a1253a2a081d5ff19888b018 (patch) | |
tree | 1042f96b6142385d6fe9e9a4d9e76ccdbe1b9666 /lib/serve.js | |
parent | f1a5a804e834cebf71c10b83197b11d8fadd26a4 (diff) | |
download | patchfoo-87a69610fde53178a1253a2a081d5ff19888b018.tar.gz patchfoo-87a69610fde53178a1253a2a081d5ff19888b018.zip |
Fix links to lightweight git tags
Diffstat (limited to 'lib/serve.js')
-rw-r--r-- | lib/serve.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js index f96c72a..424e9f3 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1938,6 +1938,7 @@ Serve.prototype.gitCommit = function (rev) { self.app.git.openObject({ obj: rev, msg: self.query.msg, + type: 'commit', }, function (err, obj) { if (err && err.name === 'BlobNotFoundError') return self.askWantBlobs(err.links) @@ -2049,9 +2050,28 @@ Serve.prototype.gitTag = 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 tag ' + rev), + self.respondSink(400) + ) + var path = '/git/tag/' + rev + + '?msg=' + encodeURIComponent(msg.key) + return self.redirect(self.app.render.toUrl(path)) + }) + } + self.app.git.openObject({ obj: rev, msg: self.query.msg, + type: 'tag', }, function (err, obj) { if (err && err.name === 'BlobNotFoundError') return self.askWantBlobs(err.links) @@ -2060,8 +2080,14 @@ Serve.prototype.gitTag = function (rev) { self.wrapPage('git tag ' + rev), self.respondSink(400) ) + var msgDate = new Date(obj.msg.value.timestamp) self.app.git.getTag(obj, function (err, tag) { + if (err && err.message === 'expected type \'tag\' but found \'commit\'') { + var path = '/git/commit/' + rev + + '?msg=' + encodeURIComponent(self.query.msg) + return self.redirect(self.app.render.toUrl(path)) + } var missingBlobs if (err && err.name === 'BlobNotFoundError') missingBlobs = err.links, err = null |