Commit 287cfa70a645df435a34f56c682ad34f826eba00
Support git-ssb multi-feed repos
%BIS2YwZPg0sdM7pe7CGdD8IIwNuqhRFBcGtEI0lvboY=.sha256Charles Lehner authored on 9/27/2016, 5:29:00 AM
cel committed on 11/1/2016, 6:07:17 PM
Parent: 2fe7cbd5b52517d67ed3f88dc1b4505ee835d992
Files changed
modules/git.js | changed |
package.json | changed |
modules/git.js | ||
---|---|---|
@@ -14,50 +14,47 @@ | ||
14 | 14 … | var sbot_get = plugs.first(exports.sbot_get = []) |
15 | 15 … | var getAvatar = require('ssb-avatar') |
16 | 16 … | var avatar_name = plugs.first(exports.avatar_name = []) |
17 | 17 … | var markdown = plugs.first(exports.markdown = []) |
18 … | +var KVGraph = require('kvgraph') | |
19 … | +var mergeRepo = require('ssb-git/merge') | |
18 | 20 … | |
19 | 21 … | var self_id = require('../keys').id |
20 | 22 … | |
21 | 23 … | function shortRefName(ref) { |
22 | 24 … | return ref.replace(/^refs\/(heads|tags)\//, '') |
23 | 25 … | } |
24 | 26 … | |
25 | 27 … | function getRefs(msg) { |
26 | - var refs = {} | |
27 | - var commitTitles = {} | |
28 | - return pull( | |
28 … | + var updates = new KVGraph('key') | |
29 … | + var _cb, _refs | |
30 … | + pull( | |
29 | 31 … | sbot_links({ |
30 | 32 … | reverse: true, |
31 | - source: msg.value.author, | |
33 … | + // source: msg.value.author, | |
32 | 34 … | dest: msg.key, |
33 | 35 … | rel: 'repo', |
34 | 36 … | values: true |
35 | 37 … | }), |
36 | - pull.map(function (link) { | |
37 | - var refUpdates = link.value.content.refs || {} | |
38 | - var commits = link.value.content.commits | |
39 | - if(commits) { | |
40 | - for(var i = 0; i < commits.length; i++) { | |
41 | - var commit = commits[i] | |
42 | - if(commit && commit.sha1 && commit.title) { | |
43 | - commitTitles[commit.sha1] = commit.title | |
44 | - } | |
45 | - } | |
38 … | + pull.drain(function (link) { | |
39 … | + if (link.value.content.type === 'git-update') { | |
40 … | + updates.add(link) | |
46 | 41 … | } |
47 | - return Object.keys(refUpdates).reverse().map(function (ref) { | |
48 | - if(refs[ref]) return | |
49 | - refs[ref] = true | |
50 | - var rev = refUpdates[ref] | |
51 | - if(!rev) return | |
52 | - return { | |
53 | - name: ref, | |
54 | - rev: rev, | |
55 | - link: link, | |
56 | - title: commitTitles[rev], | |
57 | - } | |
58 | - }).filter(Boolean) | |
59 | - }), | |
42 … | + }, function (err) { | |
43 … | + var refs = updates.reduceRight(mergeRepo).refs | |
44 … | + var cb = _cb | |
45 … | + if (cb) delete _cb, cb(err, refs) | |
46 … | + else _refs = refs | |
47 … | + }) | |
48 … | + ) | |
49 … | + | |
50 … | + return pull( | |
51 … | + function fn(end, cb) { | |
52 … | + if (end || fn.ended) cb(true) | |
53 … | + fn.ended = true | |
54 … | + if (_refs) cb(_refs) | |
55 … | + else _cb = cb | |
56 … | + }, | |
60 | 57 … | pull.flatten() |
61 | 58 … | ) |
62 | 59 … | } |
63 | 60 … | |
@@ -194,15 +191,22 @@ | ||
194 | 191 … | this.parentNode.replaceChild(pullRequestForm(msg), this) |
195 | 192 … | }}, 'New Pull Request…'))) |
196 | 193 … | |
197 | 194 … | pull(getRefs(msg), pull.drain(function (ref) { |
198 | - var parts = /^refs\/(heads|tags)\/(.*)$/.exec(ref.name) || [] | |
195 … | + var name = ref.realname || ref.name | |
196 … | + var author = ref.link && ref.link.value.author | |
197 … | + var parts = /^refs\/(heads|tags)\/(.*)$/.exec(name) || [] | |
198 … | + var shortName = parts[2] | |
199 | 199 … | var t |
200 | 200 … | if(parts[1] === 'heads') t = branchesT |
201 | 201 … | else if(parts[1] === 'tags') t = tagsT |
202 | 202 … | if(t) t.append(h('tr', |
203 | - h('td', parts[2]), | |
204 | - h('td', h('code', ref.rev)), | |
203 … | + h('td', shortName, | |
204 … | + ref.conflict ? [ | |
205 … | + h('br'), | |
206 … | + h('a', {href: '#'+author}, avatar_name(author)) | |
207 … | + ] : ''), | |
208 … | + h('td', h('code', ref.hash)), | |
205 | 209 … | h('td', messageTimestampLink(ref.link)))) |
206 | 210 … | }, function (err) { |
207 | 211 … | if(err) console.error(err) |
208 | 212 … | })) |
@@ -368,9 +372,9 @@ | ||
368 | 372 … | if(full) { |
369 | 373 … | var updated = new Date(ref.link.value.timestamp) |
370 | 374 … | label = branch + |
371 | 375 … | ' · ' + human(updated) + |
372 | - ' · ' + ref.rev.substr(1, 8) + | |
376 … | + ' · ' + ref.hash.substr(1, 8) + | |
373 | 377 … | (ref.title ? ' · "' + ref.title + '"' : '') |
374 | 378 … | } |
375 | 379 … | return h('option', {value: branch}, label) |
376 | 380 … | })) |
package.json | ||
---|---|---|
@@ -20,8 +20,9 @@ | ||
20 | 20 … | "hyperprogress": "0.1.0", |
21 | 21 … | "hyperscript": "^1.4.7", |
22 | 22 … | "hypertabs": "^2.2.0", |
23 | 23 … | "is-visible": "^2.0.4", |
24 … | + "kvgraph": "^0.1.0", | |
24 | 25 … | "map-filter-reduce": "^3.0.1", |
25 | 26 … | "mime-types": "^2.1.11", |
26 | 27 … | "moment": "^2.13.0", |
27 | 28 … | "open-external": "^0.1.1", |
@@ -38,8 +39,9 @@ | ||
38 | 39 … | "ssb-avatar": "^0.2.0", |
39 | 40 … | "ssb-client": "^4.0.3", |
40 | 41 … | "ssb-config": "^2.1.1", |
41 | 42 … | "ssb-feed": "^2.2.1", |
43 … | + "ssb-git": "^0.4.1", | |
42 | 44 … | "ssb-keys": "^6.1.0", |
43 | 45 … | "ssb-markdown": "^3.0.0", |
44 | 46 … | "ssb-mentions": "^0.1.0", |
45 | 47 … | "ssb-ref": "^2.6.2", |
Built with git-ssb-web