git ssb

0+

cel / pull-git-remote-helper



Tree: 1c27109b9155b4dd90f5068566dfc45b92a17f82

Files: 1c27109b9155b4dd90f5068566dfc45b92a17f82 / test / remote / git-remote-empty.js

1509 bytesRaw
1#!/usr/bin/env node
2
3var toPull = require('stream-to-pull-stream')
4var pull = require('pull-stream')
5var util = require('../../lib/util')
6
7process.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
14pull(
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