git ssb

0+

cel / pull-git-remote-helper



Tree: 19f56371ca30ab1b788a7f999d532d523f890469

Files: 19f56371ca30ab1b788a7f999d532d523f890469 / test / remote / git-remote-full.js

1401 bytesRaw
1#!/usr/bin/env node
2
3var toPull = require('stream-to-pull-stream')
4var pull = require('pull-stream')
5var repo = require('pull-git-pack/test/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', hash: HEAD},
17 {name: 'HEAD', hash: 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: function () { return pull.values(refs) },
35 symrefs: pull.empty,
36 wantSink: pull.drain(function (want) {
37 process.send({want: want})
38 }),
39 hasObject: function (hash, cb) {
40 cb(null, hash in hashes)
41 },
42 getObject: function (hash, cb) {
43 var item = hashes[hash]
44 if (!item) return cb(new Error('Object not present with hash ' + hash))
45 cb(null, {
46 type: item.type,
47 length: item.object.data.length,
48 read: pull.once(item.object.data)
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