Files: 0a230574cf24c936228945ed51263faaf061bfb3 / test / remote / git-remote-empty.js
1534 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 | symrefs: pull.empty, |
19 | hasObject: function (hash, cb) { cb(null, false) }, |
20 | getObject: function (hash, cb) { cb(new Error('No objects here')) }, |
21 | update: function (readRefs, readObjects) { |
22 | pull( |
23 | readRefs, |
24 | pull.drain(function (update) { |
25 | process.send({update: update}) |
26 | }, function (err) { |
27 | if (err) throw err |
28 | }) |
29 | ) |
30 | readObjects(null, function next(end, object) { |
31 | if (end === true) return |
32 | if (end) throw end |
33 | var hasher = util.createGitObjectHash(object.type, object.length) |
34 | pull( |
35 | object.read, |
36 | hasher, |
37 | pull.collect(function (err, bufs) { |
38 | if (err) throw err |
39 | var buf = Buffer.concat(bufs, object.length) |
40 | process.send({object: { |
41 | type: object.type, |
42 | data: buf.toString('ascii'), |
43 | length: object.length, |
44 | hash: hasher.digest('hex') |
45 | }}) |
46 | readObjects(null, next) |
47 | }) |
48 | ) |
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