aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index 21f45a4..9166eb2 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -905,3 +905,78 @@ App.prototype.expandOoo = function (opts, cb) {
}
}
}
+
+App.prototype.getLineComments = function (opts, cb) {
+ // get line comments for a git-update message and git object id.
+ // line comments include message id, commit id and path
+ // but we have message id and git object hash.
+ // look up the git object hash for each line-comment
+ // to verify that it is for the git object file we want
+ var updateId = opts.obj.msg.key
+ var objId = opts.hash
+ var self = this
+ var lineComments = {}
+ pull(
+ self.sbot.backlinks ? self.sbot.backlinks.read({
+ query: [
+ {$filter: {
+ dest: updateId,
+ value: {
+ content: {
+ type: 'line-comment',
+ updateId: updateId,
+ }
+ }
+ }}
+ ]
+ }) : pull(
+ self.sbot.links({
+ dest: updateId,
+ rel: 'updateId',
+ values: true
+ }),
+ pull.filter(function (msg) {
+ var c = msg && msg.value && msg.value.content
+ return c && c.type === 'line-comment'
+ && c.updateId === updateId
+ })
+ ),
+ paramap(function (msg, cb) {
+ var c = msg.value.content
+ self.git.getObjectAtPath({
+ msg: updateId,
+ obj: c.commitId,
+ path: c.filePath,
+ }, function (err, info) {
+ if (err) return cb(err)
+ cb(null, {
+ obj: info.obj,
+ hash: info.hash,
+ msg: msg,
+ })
+ })
+ }, 4),
+ pull.filter(function (info) {
+ return info.hash === objId
+ }),
+ pull.drain(function (info) {
+ lineComments[info.msg.value.content.line] = info
+ }, function (err) {
+ cb(err, lineComments)
+ })
+ )
+}
+
+App.prototype.getThread = function (msg) {
+ return cat([
+ pull.once(msg),
+ this.sbot.backlinks ? this.sbot.backlinks.read({
+ query: [
+ {$filter: {dest: msg.key}}
+ ]
+ }) : this.sbot.links({
+ dest: msg.key,
+ values: true
+ })
+ ])
+}