git ssb

30+

cel / git-ssb-web



Commit 9c3452530e296365dce5b439655e7ae70f4d1f44

Support channel repos better

cel committed on 12/6/2017, 9:08:02 PM
Parent: ce68a9919500012226d1d1cfcb25b664e69a3d41

Files changed

lib/repos/index.jschanged
lib/repos/pulls.jschanged
lib/repos/index.jsView
@@ -109,9 +109,15 @@
109109 return h('div', [
110110 pull(
111111 cat([
112112 pull.once(msg),
113- self.web.ssb.links({
113 + self.web.ssb.backlinks ? self.web.ssb.backlinks.read({
114 + query: [
115 + {$filter: {
116 + dest: root
117 + }}
118 + ]
119 + }) : self.web.ssb.links({
114120 dest: root,
115121 values: true
116122 }),
117123 ]),
@@ -443,9 +449,20 @@
443449 var title = req._t('Activity') + ' · %{author}/%{repo}'
444450 return self.serveRepoTemplate(req, repo, 'activity', branch, title, cat([
445451 h('h3', req._t('Activity')),
446452 pull(
447- self.web.ssb.links({
453 + self.web.ssb.backlinks ? self.web.ssb.backlinks.read({
454 + query: [
455 + {$filter: {
456 + dest: repo.id,
457 + value: {
458 + content: {
459 + repo: repo.id
460 + }
461 + }
462 + }}
463 + ]
464 + }) : self.web.ssb.links({
448465 dest: repo.id,
449466 rel: 'repo',
450467 values: true
451468 }),
@@ -1105,31 +1122,65 @@
11051122 cat([
11061123 includeSelf && pull.once(repo.id),
11071124 // get downstream repos
11081125 pull(
1109- self.web.ssb.links({
1110- dest: repo.id,
1111- rel: 'upstream'
1112- }),
1113- pull.map('key')
1126 + self.web.ssb.backlinks ? self.web.ssb.backlinks.read({
1127 + query: [
1128 + {$filter: {
1129 + dest: repo.id,
1130 + value: {
1131 + content: {
1132 + type: 'git-repo',
1133 + upstream: repo.id,
1134 + }
1135 + }
1136 + }},
1137 + {$map: 'key'}
1138 + ]
1139 + }) : pull(
1140 + self.web.ssb.links({
1141 + dest: repo.id,
1142 + rel: 'upstream'
1143 + }),
1144 + pull.map('key')
1145 + )
11141146 ),
11151147 // look for other repos that previously had pull requests to this one
11161148 pull(
1117- self.web.ssb.links({
1118- dest: repo.id,
1119- values: true,
1120- rel: 'project'
1121- }),
1122- u.decryptMessages(self.web.ssb),
1123- pull.filter(function (msg) {
1124- var c = msg && msg.value && msg.value.content
1125- return c && c.type == 'pull-request'
1126- }),
1149 + self.web.ssb.backlinks ? self.web.ssb.backlinks.read({
1150 + query: [
1151 + {$filter: {
1152 + dest: repo.id,
1153 + value: {
1154 + content: {
1155 + type: 'pull-request',
1156 + project: repo.id,
1157 + }
1158 + }
1159 + }}
1160 + ]
1161 + }) : pull(
1162 + self.web.ssb.links({
1163 + dest: repo.id,
1164 + values: true,
1165 + rel: 'project'
1166 + }),
1167 + u.decryptMessages(self.web.ssb),
1168 + pull.filter(function (msg) {
1169 + var c = msg && msg.value && msg.value.content
1170 + return c && c.type == 'pull-request'
1171 + })
1172 + ),
11271173 pull.map(function (msg) { return msg.value.content.head_repo })
11281174 )
11291175 ]),
11301176 pull.unique(),
11311177 paramap(function (key, cb) {
1178 + if (key && key[0] === '#') return cb(null, {key: key, value: {
1179 + content: {
1180 + type: 'git-repo',
1181 + }
1182 + }})
11321183 self.web.getMsg(key, cb)
11331184 }, 4),
11341185 u.decryptMessages(self.web.ssb),
11351186 pull.filter(function (msg) {
lib/repos/pulls.jsView
@@ -345,10 +345,10 @@
345345 }
346346
347347 if (!baseBranch)
348348 return self.web.serveRedirect(req, u.encodeLink([repo.id, 'compare']))
349- if (!ssbRef.isMsgId(headRepoId))
350- return self.web.serveError(req, new Error('bad repo id'), 400)
349 + if (!ssbRef.isMsgId(headRepoId) && !/^#/.test(headRepoId))
350 + return self.web.serveError(req, new Error('bad repo id: ' + headRepoId), 400)
351351
352352 var baseLink = u.link([repo.id, 'tree', baseBranch])
353353 var headBranchLink = u.link([headRepoId, 'tree', headBranch])
354354 var backHref = u.encodeLink([repo.id, 'compare']) + req._u.search

Built with git-ssb-web