git ssb

0+

cel / pull-git-remote-helper



Tree: a53fb68ffb75c9fc0ff72ebbe56746e37f323cdc

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

1300 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
26var hashes = {}
27hashes[repo.commit.hash] = objects[0]
28hashes[repo.tree.hash] = objects[1]
29hashes[repo.file.hash] = objects[2]
30
31pull(
32 toPull(process.stdin),
33 require('../../')({
34 refs: pull.values(refs),
35 wantSink: pull.drain(function (want) {
36 process.send({want: want})
37 }),
38 hasObject: function (hash, cb) {
39 cb(null, hash in hashes)
40 },
41 getObject: function (hash, cb) {
42 var item = hashes[hash]
43 if (!item) return cb(null, null)
44 cb(null, {
45 type: item.type,
46 length: item.object.data.length,
47 read: pull.once(item.object.data)
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