git ssb

0+

cel / pull-git-remote-helper



Tree: 666eaeb2e3d956c1c7e70c3e279e5b993a71a829

Files: 666eaeb2e3d956c1c7e70c3e279e5b993a71a829 / test / remote / git-remote-full.js

1320 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 refSource: pull.values(refs),
41 wantSink: pull.drain(function (want) {
42 process.send({want: want})
43 }),
44 getObjects: function (ancestorHash, cb) {
45 // console.error('get obj!', ancestorHash)
46 cb(null, objects.length, pull(
47 pull.values(objects),
48 streamObject
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