Commit b57e8b80419ea2fb7cf7d3b5281d371a2b3976c0
Move remote helpers into subdir
Charles Lehner committed on 2/8/2016, 4:37:24 AMParent: c2f96fca4e0046fd6b5ee048898f8db2c2c1d247
Files changed
package.json | changed |
test/run.js | changed |
test/git-remote-empty.js | deleted |
test/remote/git-remote-empty.js | added |
test/remote/git-remote-full.js | added |
test/git-remote-full.js | deleted |
package.json | ||
---|---|---|
@@ -3,9 +3,9 @@ | ||
3 | 3 | "version": "0.0.0", |
4 | 4 | "description": "use pull-streams to make gitremote-helpers(1)", |
5 | 5 | "main": "index.js", |
6 | 6 | "scripts": { |
7 | - "test": "node test/run.js" | |
7 | + "test": "tape test/*.js" | |
8 | 8 | }, |
9 | 9 | "repository": { |
10 | 10 | "type": "git", |
11 | 11 | "url": "git://github.com/clehner/pull-git-remote-helper" |
test/run.js | ||
---|---|---|
@@ -6,9 +6,9 @@ | ||
6 | 6 | var fs = require('fs') |
7 | 7 | var repo = require('./repo') |
8 | 8 | |
9 | 9 | var env = Object.create(process.env) |
10 | -env.PATH = __dirname + ':' + env.PATH | |
10 | +env.PATH = path.join(__dirname, 'remote') + ':' + env.PATH | |
11 | 11 | env.GIT_AUTHOR_DATE = env.GIT_COMMITTER_DATE = repo.date |
12 | 12 | var user = repo.user |
13 | 13 | var remote = { |
14 | 14 | empty: 'empty.js://', |
test/git-remote-empty.js | ||
---|---|---|
@@ -1,50 +1,0 @@ | ||
1 | -#!/usr/bin/env node | |
2 | - | |
3 | -var toPull = require('stream-to-pull-stream') | |
4 | -var pull = require('pull-stream') | |
5 | -var util = require('../util') | |
6 | - | |
7 | -process.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 | - | |
14 | -pull( | |
15 | - toPull(process.stdin), | |
16 | - require('../')({ | |
17 | - prefix: 'foo', | |
18 | - objectSink: function (readObject) { | |
19 | - readObject(null, function next(end, type, length, read) { | |
20 | - if (end === true) return | |
21 | - if (end) throw end | |
22 | - var hasher = util.createGitObjectHash(type, length) | |
23 | - pull( | |
24 | - read, | |
25 | - hasher, | |
26 | - pull.collect(function (err, bufs) { | |
27 | - if (err) throw err | |
28 | - var buf = Buffer.concat(bufs) | |
29 | - console.error('obj', type, length, JSON.stringify(buf.toString('ascii'))) | |
30 | - process.send({object: { | |
31 | - type: type, | |
32 | - data: buf.toString('ascii'), | |
33 | - length: length, | |
34 | - hash: hasher.digest('hex') | |
35 | - }}) | |
36 | - readObject(null, next) | |
37 | - }) | |
38 | - ) | |
39 | - }) | |
40 | - }, | |
41 | - refSink: pull.drain(function (ref) { | |
42 | - process.send({ref: ref}) | |
43 | - }) | |
44 | - }), | |
45 | - toPull(process.stdout, function (err) { | |
46 | - if (err) | |
47 | - throw err | |
48 | - process.disconnect() | |
49 | - }) | |
50 | -) |
test/remote/git-remote-empty.js | ||
---|---|---|
@@ -1,0 +1,50 @@ | ||
1 | +#!/usr/bin/env node | |
2 | + | |
3 | +var toPull = require('stream-to-pull-stream') | |
4 | +var pull = require('pull-stream') | |
5 | +var util = require('../../util') | |
6 | + | |
7 | +process.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 | + | |
14 | +pull( | |
15 | + toPull(process.stdin), | |
16 | + require('../../')({ | |
17 | + prefix: 'foo', | |
18 | + objectSink: function (readObject) { | |
19 | + readObject(null, function next(end, type, length, read) { | |
20 | + if (end === true) return | |
21 | + if (end) throw end | |
22 | + var hasher = util.createGitObjectHash(type, length) | |
23 | + pull( | |
24 | + read, | |
25 | + hasher, | |
26 | + pull.collect(function (err, bufs) { | |
27 | + if (err) throw err | |
28 | + var buf = Buffer.concat(bufs) | |
29 | + console.error('obj', type, length, JSON.stringify(buf.toString('ascii'))) | |
30 | + process.send({object: { | |
31 | + type: type, | |
32 | + data: buf.toString('ascii'), | |
33 | + length: length, | |
34 | + hash: hasher.digest('hex') | |
35 | + }}) | |
36 | + readObject(null, next) | |
37 | + }) | |
38 | + ) | |
39 | + }) | |
40 | + }, | |
41 | + refSink: pull.drain(function (ref) { | |
42 | + process.send({ref: ref}) | |
43 | + }) | |
44 | + }), | |
45 | + toPull(process.stdout, function (err) { | |
46 | + if (err) | |
47 | + throw err | |
48 | + process.disconnect() | |
49 | + }) | |
50 | +) |
test/remote/git-remote-full.js | ||
---|---|---|
@@ -1,0 +1,58 @@ | ||
1 | +#!/usr/bin/env node | |
2 | + | |
3 | +var toPull = require('stream-to-pull-stream') | |
4 | +var pull = require('pull-stream') | |
5 | +var repo = require('../repo') | |
6 | + | |
7 | +process.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 | + | |
14 | +var HEAD = 'edb5b50e8019797925820007d318870f8c346726' | |
15 | +var refs = [ | |
16 | + {name: 'refs/heads/master', value: HEAD}, | |
17 | + {name: 'HEAD', value: HEAD} | |
18 | +] | |
19 | + | |
20 | +var objects = [ | |
21 | + {type: 'commit', object: repo.commit}, | |
22 | + {type: 'tree', object: repo.tree}, | |
23 | + {type: 'blob', object: repo.file} | |
24 | +] | |
25 | + | |
26 | +function 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 | + | |
37 | +pull( | |
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 | +) |
test/git-remote-full.js | ||
---|---|---|
@@ -1,58 +1,0 @@ | ||
1 | -#!/usr/bin/env node | |
2 | - | |
3 | -var toPull = require('stream-to-pull-stream') | |
4 | -var pull = require('pull-stream') | |
5 | -var repo = require('./repo') | |
6 | - | |
7 | -process.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 | - | |
14 | -var HEAD = 'edb5b50e8019797925820007d318870f8c346726' | |
15 | -var refs = [ | |
16 | - {name: 'refs/heads/master', value: HEAD}, | |
17 | - {name: 'HEAD', value: HEAD} | |
18 | -] | |
19 | - | |
20 | -var objects = [ | |
21 | - {type: 'commit', object: repo.commit}, | |
22 | - {type: 'tree', object: repo.tree}, | |
23 | - {type: 'blob', object: repo.file} | |
24 | -] | |
25 | - | |
26 | -function 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 | - | |
37 | -pull( | |
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 | -) |
Built with git-ssb-web