git ssb

0+

cel / pull-git-remote-helper



Tree: bed0b983a87d456d6c072f88bb5f7081614d4ed1

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

1271 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 cb(null, objects.length, pull(
46 pull.values(objects),
47 streamObject
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