test/remote/git-remote-empty.jsView |
---|
1 | 1 | #!/usr/bin/env node |
2 | 2 | |
3 | 3 | var toPull = require('stream-to-pull-stream') |
4 | 4 | var pull = require('pull-stream') |
5 | | -var createGitObjectHash = require('pull-git-pack/lib/util').createGitObjectHash |
| 5 | +var createGitHash = require('pull-hash/ext/git') |
| 6 | +var multicb = require('multicb') |
6 | 7 | |
7 | 8 | process.on('uncaughtException', function (err) { |
8 | 9 | if (err.stack) |
9 | 10 | err = {stack: err.stack, message: err.message} |
29 | 30 | ) |
30 | 31 | readObjects(null, function next(end, object) { |
31 | 32 | if (end === true) return |
32 | 33 | if (end) throw end |
33 | | - var hasher = createGitObjectHash(object.type, object.length) |
| 34 | + var done = multicb({ pluck: 1, spread: true }) |
34 | 35 | pull( |
35 | 36 | object.read, |
36 | | - hasher, |
37 | | - pull.collect(function (err, bufs) { |
38 | | - if (err) throw err |
39 | | - var buf = Buffer.concat(bufs, object.length) |
40 | | - process.send({object: { |
41 | | - type: object.type, |
42 | | - data: buf.toString('ascii'), |
43 | | - length: object.length, |
44 | | - hash: hasher.digest('hex') |
45 | | - }}) |
46 | | - readObjects(null, next) |
47 | | - }) |
| 37 | + createGitObjectHash(object, done()), |
| 38 | + pull.collect(done()) |
48 | 39 | ) |
| 40 | + done(function (err, id, bufs) { |
| 41 | + if (err) throw err |
| 42 | + var buf = Buffer.concat(bufs, object.length) |
| 43 | + process.send({object: { |
| 44 | + type: object.type, |
| 45 | + data: buf.toString('ascii'), |
| 46 | + length: object.length, |
| 47 | + hash: id |
| 48 | + }}) |
| 49 | + readObjects(null, next) |
| 50 | + }) |
49 | 51 | }) |
50 | 52 | } |
51 | 53 | }), |
52 | 54 | toPull(process.stdout, function (err) { |