git ssb

0+

cel / pull-git-remote-helper



Commit 89810d797532892ef70d5ee23f3b82c5466e7858

Get test working

Charles Lehner committed on 2/8/2016, 4:36:42 AM
Parent: cc32919e93ce91c6d66985c7ca2b78da5ea7f92d

Files changed

index.jschanged
package.jsonchanged
test/run.jschanged
index.jsView
@@ -140,9 +140,8 @@
140140 if (ended = end) return cb(end)
141141 var len = parseInt(buf, 16)
142142 b.chunks(len)(null, function (end, buf) {
143143 if (ended = end) return cb(end)
144- console.error('refline', buf)
145144 cb(end, buf)
146145 })
147146 })
148147 }
@@ -198,11 +197,13 @@
198197
199198 function receiveRefs(readLine, cb) {
200199 var refs = []
201200 readLine(null, function next(end, line) {
201+ /*
202202 if (end === true)
203203 cb(new Error('refs line ended early'))
204- else if (end)
204+ else */
205+ if (end)
205206 cb(end)
206207 else if (line === '')
207208 cb(null, refs)
208209 else {
@@ -281,9 +282,9 @@
281282 return handleConnect(args[1], read)
282283 case 'option':
283284 return optionSource(args[1])
284285 default:
285- return pull.error(new Error('Unknown command ' + args[0]))
286+ return pull.error(new Error('Unknown command ' + line))
286287 }
287288 }
288289
289290 return function (read) {
@@ -291,12 +292,15 @@
291292 b(read)
292293 var command
293294
294295 function getCommand(cb) {
295- b.lines(null, function (end, line) {
296+ b.lines(null, function next(end, line) {
296297 if (ended = end)
297298 return cb(end)
298299
300+ if (line == '')
301+ return b.lines(null, next)
302+
299303 if (options.verbosity > 1)
300304 console.error('command:', line)
301305
302306 var cmdSource = handleCommand(line, b.passthrough)
package.jsonView
@@ -28,8 +28,10 @@
2828 "pull-stream": "^3.1.0",
2929 "stream-to-pull-stream": "^1.6.6"
3030 },
3131 "devDependencies": {
32+ "mktemp": "^0.4.0",
3233 "pull-stream": "^3.1.0",
34+ "rimraf": "^2.5.1",
3335 "tape": "^4.4.0"
3436 }
3537 }
test/run.jsView
@@ -1,20 +1,38 @@
11 var spawn = require('child_process').spawn
22 var tape = require('tape')
3+var path = require('path')
4+var mktemp = require('mktemp')
5+var rimraf = require('rimraf')
36
47 var env = Object.create(process.env)
5-env.PATH = 'test:' + env.PATH
8+env.PATH = __dirname + ':' + env.PATH
69 var remote = 'test.js://foo'
710
11+var tmpDir = mktemp.createDirSync(path.join(require('os').tmpdir(), 'XXXXXXX'))
12+
813 function git(args, cb) {
914 spawn('git', args, {
1015 env: env,
11- stdio: ['ignore', 'ignore', 'inherit']
16+ cwd: tmpDir,
17+ stdio: ['ignore', process.stderr, process.stderr]
1218 }).on('close', cb)
1319 }
1420
15-tape('push to the remote', function (t) {
21+tape('init repo', function (t) {
22+ git(['init'], function (code) {
23+ t.equals(code, 0, 'inited')
24+ t.end()
25+ })
26+})
27+
28+tape('push with empty repo', function (t) {
1629 git(['push', remote], function (code) {
17- t.equals(code, 0, 'exit status')
30+ t.equals(code, 0, 'pushed')
1831 t.end()
1932 })
2033 })
34+
35+tape.onFinish(function () {
36+ if (tmpDir)
37+ rimraf.sync(tmpDir)
38+})

Built with git-ssb-web