Files: 8a63bcabec8cc007fe7e2ba0ae022ca50dc594dd / test / remote / git-remote-full.js
1401 bytesRaw
1 | |
2 | |
3 | var toPull = require('stream-to-pull-stream') |
4 | var pull = require('pull-stream') |
5 | var repo = require('pull-git-pack/test/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', hash: HEAD}, |
17 | {name: 'HEAD', hash: 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 | var hashes = {} |
27 | hashes[repo.commit.hash] = objects[0] |
28 | hashes[repo.tree.hash] = objects[1] |
29 | hashes[repo.file.hash] = objects[2] |
30 | |
31 | pull( |
32 | toPull(process.stdin), |
33 | require('../../')({ |
34 | refs: function () { return pull.values(refs) }, |
35 | symrefs: pull.empty, |
36 | wantSink: pull.drain(function (want) { |
37 | process.send({want: want}) |
38 | }), |
39 | hasObject: function (hash, cb) { |
40 | cb(null, hash in hashes) |
41 | }, |
42 | getObject: function (hash, cb) { |
43 | var item = hashes[hash] |
44 | if (!item) return cb(new Error('Object not present with hash ' + hash)) |
45 | cb(null, { |
46 | type: item.type, |
47 | length: item.object.data.length, |
48 | read: pull.once(item.object.data) |
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