git ssb

16+

Dominic / patchbay



Commit 287cfa70a645df435a34f56c682ad34f826eba00

Support git-ssb multi-feed repos

%BIS2YwZPg0sdM7pe7CGdD8IIwNuqhRFBcGtEI0lvboY=.sha256
Charles 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.jschanged
package.jsonchanged
modules/git.jsView
@@ -14,50 +14,47 @@
1414 var sbot_get = plugs.first(exports.sbot_get = [])
1515 var getAvatar = require('ssb-avatar')
1616 var avatar_name = plugs.first(exports.avatar_name = [])
1717 var markdown = plugs.first(exports.markdown = [])
18 +var KVGraph = require('kvgraph')
19 +var mergeRepo = require('ssb-git/merge')
1820
1921 var self_id = require('../keys').id
2022
2123 function shortRefName(ref) {
2224 return ref.replace(/^refs\/(heads|tags)\//, '')
2325 }
2426
2527 function getRefs(msg) {
26- var refs = {}
27- var commitTitles = {}
28- return pull(
28 + var updates = new KVGraph('key')
29 + var _cb, _refs
30 + pull(
2931 sbot_links({
3032 reverse: true,
31- source: msg.value.author,
33 + // source: msg.value.author,
3234 dest: msg.key,
3335 rel: 'repo',
3436 values: true
3537 }),
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)
4641 }
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 + },
6057 pull.flatten()
6158 )
6259 }
6360
@@ -194,15 +191,22 @@
194191 this.parentNode.replaceChild(pullRequestForm(msg), this)
195192 }}, 'New Pull Request…')))
196193
197194 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]
199199 var t
200200 if(parts[1] === 'heads') t = branchesT
201201 else if(parts[1] === 'tags') t = tagsT
202202 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)),
205209 h('td', messageTimestampLink(ref.link))))
206210 }, function (err) {
207211 if(err) console.error(err)
208212 }))
@@ -368,9 +372,9 @@
368372 if(full) {
369373 var updated = new Date(ref.link.value.timestamp)
370374 label = branch +
371375 ' · ' + human(updated) +
372- ' · ' + ref.rev.substr(1, 8) +
376 + ' · ' + ref.hash.substr(1, 8) +
373377 (ref.title ? ' · "' + ref.title + '"' : '')
374378 }
375379 return h('option', {value: branch}, label)
376380 }))
package.jsonView
@@ -20,8 +20,9 @@
2020 "hyperprogress": "0.1.0",
2121 "hyperscript": "^1.4.7",
2222 "hypertabs": "^2.2.0",
2323 "is-visible": "^2.0.4",
24 + "kvgraph": "^0.1.0",
2425 "map-filter-reduce": "^3.0.1",
2526 "mime-types": "^2.1.11",
2627 "moment": "^2.13.0",
2728 "open-external": "^0.1.1",
@@ -38,8 +39,9 @@
3839 "ssb-avatar": "^0.2.0",
3940 "ssb-client": "^4.0.3",
4041 "ssb-config": "^2.1.1",
4142 "ssb-feed": "^2.2.1",
43 + "ssb-git": "^0.4.1",
4244 "ssb-keys": "^6.1.0",
4345 "ssb-markdown": "^3.0.0",
4446 "ssb-mentions": "^0.1.0",
4547 "ssb-ref": "^2.6.2",

Built with git-ssb-web