Files: 666eaeb2e3d956c1c7e70c3e279e5b993a71a829 / test / remote / git-remote-full.js
1320 bytesRaw
1 | |
2 | |
3 | var toPull = require('stream-to-pull-stream') |
4 | var pull = require('pull-stream') |
5 | var repo = require('../repo') |
6 | |
7 | process.on('uncaughtException', function (err) { |
8 | if (err.stack) |
9 | err = {stack: err.stack, message: err.message} |
10 | process.send({error: err}) |
11 | process.exit(1) |
12 | }) |
13 | |
14 | var HEAD = 'edb5b50e8019797925820007d318870f8c346726' |
15 | var refs = [ |
16 | {name: 'refs/heads/master', value: HEAD}, |
17 | {name: 'HEAD', value: HEAD} |
18 | ] |
19 | |
20 | var objects = [ |
21 | {type: 'commit', object: repo.commit}, |
22 | {type: 'tree', object: repo.tree}, |
23 | {type: 'blob', object: repo.file} |
24 | ] |
25 | |
26 | function streamObject(read) { |
27 | var ended |
28 | return function readObject(abort, cb) { |
29 | read(abort, function (end, item) { |
30 | if (ended = end) return cb(end) |
31 | var data = item.object.data |
32 | cb(null, item.type, data.length, pull.once(data)) |
33 | }) |
34 | } |
35 | } |
36 | |
37 | pull( |
38 | toPull(process.stdin), |
39 | require('../../')({ |
40 | refSource: pull.values(refs), |
41 | wantSink: pull.drain(function (want) { |
42 | process.send({want: want}) |
43 | }), |
44 | getObjects: function (ancestorHash, cb) { |
45 | // console.error('get obj!', ancestorHash) |
46 | cb(null, objects.length, pull( |
47 | pull.values(objects), |
48 | streamObject |
49 | )) |
50 | } |
51 | }), |
52 | toPull(process.stdout, function (err) { |
53 | if (err) |
54 | throw err |
55 | process.disconnect() |
56 | }) |
57 | ) |
58 |
Built with git-ssb-web