Files: 4435fc8900324c433d7c0e31c8a5bda3a5ee53e0 / test / remote / git-remote-empty.js
1570 bytesRaw
1 | |
2 | |
3 | var toPull = require('stream-to-pull-stream') |
4 | var pull = require('pull-stream') |
5 | var createGitHash = require('pull-hash/ext/git') |
6 | var multicb = require('multicb') |
7 | |
8 | process.on('uncaughtException', function (err) { |
9 | if (err.stack) |
10 | err = {stack: err.stack, message: err.message} |
11 | process.send({error: err}) |
12 | process.exit(1) |
13 | }) |
14 | |
15 | pull( |
16 | toPull(process.stdin), |
17 | require('../../')({ |
18 | refs: pull.empty, |
19 | symrefs: pull.empty, |
20 | hasObject: function (hash, cb) { cb(null, false) }, |
21 | getObject: function (hash, cb) { cb(new Error('No objects here')) }, |
22 | update: function (readRefs, readObjects) { |
23 | pull( |
24 | readRefs, |
25 | pull.drain(function (update) { |
26 | process.send({update: update}) |
27 | }, function (err) { |
28 | if (err) throw err |
29 | }) |
30 | ) |
31 | readObjects(null, function next(end, object) { |
32 | if (end === true) return |
33 | if (end) throw end |
34 | var done = multicb({ pluck: 1, spread: true }) |
35 | pull( |
36 | object.read, |
37 | createGitHash(object, done()), |
38 | pull.collect(done()) |
39 | ) |
40 | done(function (err, id, bufs) { |
41 | if (err) throw err |
42 | var buf = Buffer.concat(bufs, object.length) |
43 | process.send({object: { |
44 | type: object.type, |
45 | data: buf.toString('ascii'), |
46 | length: object.length, |
47 | hash: id |
48 | }}) |
49 | readObjects(null, next) |
50 | }) |
51 | }) |
52 | } |
53 | }), |
54 | toPull(process.stdout, function (err) { |
55 | if (err) |
56 | throw err |
57 | process.disconnect() |
58 | }) |
59 | ) |
60 |
Built with git-ssb-web