git ssb

0+

cel / pull-git-remote-helper



Tree: 146a443d177d4fac8520cac615abdb421a4df30e

Files: 146a443d177d4fac8520cac615abdb421a4df30e / test / remote / git-remote-empty.js

1570 bytesRaw
1#!/usr/bin/env node
2
3var toPull = require('stream-to-pull-stream')
4var pull = require('pull-stream')
5var createGitHash = require('pull-hash/ext/git')
6var multicb = require('multicb')
7
8process.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
15pull(
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