Commit 4b7ce5c14199fc8355081ad1b019b154f20393cc
Move index-pack into pull-git-pack
Charles Lehner committed on 3/22/2016, 3:41:11 AMParent: 146a443d177d4fac8520cac615abdb421a4df30e
Files changed
index.js | changed |
lib/index-pack.js | deleted |
package.json | changed |
test/index-pack.js | deleted |
index.js | ||
---|---|---|
@@ -4,9 +4,9 @@ | ||
4 | 4 | var buffered = require('pull-buffered') |
5 | 5 | var Repo = require('pull-git-repo') |
6 | 6 | var pack = require('pull-git-pack') |
7 | 7 | var pktLine = require('./lib/pkt-line') |
8 | -var indexPack = require('./lib/index-pack') | |
8 | +var indexPack = require('pull-git-pack/lib/index-pack') | |
9 | 9 | var util = require('./lib/util') |
10 | 10 | var multicb = require('multicb') |
11 | 11 | var ProgressBar = require('progress') |
12 | 12 |
lib/index-pack.js | ||
---|---|---|
@@ -1,35 +1,0 @@ | ||
1 | -var pull = require('pull-stream') | |
2 | -var toPull = require('stream-to-pull-stream') | |
3 | -var cp = require('child_process') | |
4 | -var fs = require('fs') | |
5 | -var path = require('path') | |
6 | -var os = require('os') | |
7 | - | |
8 | -module.exports = function (packFile, cb) { | |
9 | - var name = Math.random().toString(36).substr(2) | |
10 | - var indexFilename = path.join(os.tmpdir(), name + '.idx') | |
11 | - var packFilename = path.join(os.tmpdir(), name + '.pack') | |
12 | - | |
13 | - var child = cp.spawn('git', ['index-pack', '--stdin', '--fix-thin', | |
14 | - '-o', indexFilename, packFilename], { | |
15 | - stdio: ['pipe', 'pipe', 'inherit'] | |
16 | - }) | |
17 | - pull(packFile, toPull.sink(child.stdin)) | |
18 | - child.on('close', function (err) { | |
19 | - if (err) return cb(new Error('git index-pack returned ' + err)) | |
20 | - cb(null, | |
21 | - toPull(fs.createReadStream(indexFilename), function (err) { | |
22 | - fs.unlink(indexFilename, function (err) { | |
23 | - if (err) return console.error(err) | |
24 | - }) | |
25 | - }), | |
26 | - // the output packfile here is the original packfile transformed to make | |
27 | - // it not thin. | |
28 | - toPull(fs.createReadStream(packFilename), function (err) { | |
29 | - fs.unlink(packFilename, function (err) { | |
30 | - if (err) return console.error(err) | |
31 | - }) | |
32 | - }) | |
33 | - ) | |
34 | - }) | |
35 | -} |
package.json | ||
---|---|---|
@@ -27,9 +27,9 @@ | ||
27 | 27 | "progress": "^1.1.8", |
28 | 28 | "pull-buffered": "^0.3.1", |
29 | 29 | "pull-cache": "^0.0.0", |
30 | 30 | "pull-cat": "^1.1.8", |
31 | - "pull-git-pack": "^0.1.1", | |
31 | + "pull-git-pack": "^0.1.2", | |
32 | 32 | "pull-git-repo": "^0.2.2", |
33 | 33 | "pull-hash": "^0.0.0", |
34 | 34 | "pull-stream": "^3.1.0", |
35 | 35 | "stream-to-pull-stream": "^1.6.6" |
test/index-pack.js | ||
---|---|---|
@@ -1,21 +1,0 @@ | ||
1 | -var tape = require('tape') | |
2 | -var indexPack = require('../lib/index-pack') | |
3 | -var pull = require('pull-stream') | |
4 | -var toPull = require('stream-to-pull-stream') | |
5 | -var cp = require('child_process') | |
6 | - | |
7 | -tape('index-pack produces output', function (t) { | |
8 | - var child = cp.spawn('git', ['pack-objects', '--stdout', '--revs']) | |
9 | - child.stdin.end('HEAD\n') | |
10 | - indexPack(toPull.source(child.stdout), function (err, idx) { | |
11 | - t.error(err, 'index pack') | |
12 | - pull(idx, pull.reduce(function (val, buf) { | |
13 | - return val + buf.length | |
14 | - }, 0, function (err, length) { | |
15 | - t.error(err, 'read index pack') | |
16 | - t.comment('len: ' + length) | |
17 | - t.ok(length > 0, 'length') | |
18 | - t.end() | |
19 | - })) | |
20 | - }) | |
21 | -}) |
Built with git-ssb-web