git ssb

0+

cel / pull-git-remote-helper



Tree: c2f96fca4e0046fd6b5ee048898f8db2c2c1d247

Files: c2f96fca4e0046fd6b5ee048898f8db2c2c1d247 / test / git-remote-full.js

1335 bytesRaw
1#!/usr/bin/env node
2
3var toPull = require('stream-to-pull-stream')
4var pull = require('pull-stream')
5var repo = require('./repo')
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
14var HEAD = 'edb5b50e8019797925820007d318870f8c346726'
15var refs = [
16 {name: 'refs/heads/master', value: HEAD},
17 {name: 'HEAD', value: HEAD}
18]
19
20var objects = [
21 {type: 'commit', object: repo.commit},
22 {type: 'tree', object: repo.tree},
23 {type: 'blob', object: repo.file}
24]
25
26function streamObject(read) {
27 var ended
28 return function readObject(abort, cb) {
29 read(abort, function (end, item) {
30 if (ended = end) return cb(end)
31 var data = item.object.data
32 cb(null, item.type, data.length, pull.once(data))
33 })
34 }
35}
36
37pull(
38 toPull(process.stdin),
39 require('../')({
40 prefix: 'foo',
41 refSource: pull.values(refs),
42 wantSink: pull.drain(function (want) {
43 process.send({want: want})
44 }),
45 getObjects: function (ancestorHash, cb) {
46 // console.error('get obj!', ancestorHash)
47 cb(null, objects.length, pull(
48 pull.values(objects),
49 streamObject
50 ))
51 }
52 }),
53 toPull(process.stdout, function (err) {
54 if (err)
55 throw err
56 process.disconnect()
57 })
58)
59

Built with git-ssb-web