Files: 6198d3e1ad4b68fee408f6eade0a3ec353c06a25 / test / remote / git-remote-empty.js
1511 bytesRaw
1 | |
2 | |
3 | var toPull = require('stream-to-pull-stream') |
4 | var pull = require('pull-stream') |
5 | var util = require('../../lib/util') |
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 | pull( |
15 | toPull(process.stdin), |
16 | require('../../')({ |
17 | refs: pull.empty(), |
18 | hasObject: function (hash, cb) { cb(null, false) }, |
19 | getObject: function (hash, cb) { cb(new Error('No objects here')) }, |
20 | update: function (readRefs, readObjects) { |
21 | pull( |
22 | readRefs, |
23 | pull.drain(function (update) { |
24 | process.send({update: update}) |
25 | }, function (err) { |
26 | if (err) throw err |
27 | }) |
28 | ) |
29 | readObjects(null, function next(end, object) { |
30 | if (end === true) return |
31 | if (end) throw end |
32 | var hasher = util.createGitObjectHash(object.type, object.length) |
33 | pull( |
34 | object.read, |
35 | hasher, |
36 | pull.collect(function (err, bufs) { |
37 | if (err) throw err |
38 | var buf = Buffer.concat(bufs, object.length) |
39 | process.send({object: { |
40 | type: object.type, |
41 | data: buf.toString('ascii'), |
42 | length: object.length, |
43 | hash: hasher.digest('hex') |
44 | }}) |
45 | readObjects(null, next) |
46 | }) |
47 | ) |
48 | }) |
49 | } |
50 | }), |
51 | toPull(process.stdout, function (err) { |
52 | if (err) |
53 | throw err |
54 | process.disconnect() |
55 | }) |
56 | ) |
57 |
Built with git-ssb-web