git ssb

0+

cel / pull-git-remote-helper



Commit 4b7ce5c14199fc8355081ad1b019b154f20393cc

Move index-pack into pull-git-pack

Charles Lehner committed on 3/22/2016, 3:41:11 AM
Parent: 146a443d177d4fac8520cac615abdb421a4df30e

Files changed

index.jschanged
lib/index-pack.jsdeleted
package.jsonchanged
test/index-pack.jsdeleted
index.jsView
@@ -4,9 +4,9 @@
44 var buffered = require('pull-buffered')
55 var Repo = require('pull-git-repo')
66 var pack = require('pull-git-pack')
77 var pktLine = require('./lib/pkt-line')
8-var indexPack = require('./lib/index-pack')
8+var indexPack = require('pull-git-pack/lib/index-pack')
99 var util = require('./lib/util')
1010 var multicb = require('multicb')
1111 var ProgressBar = require('progress')
1212
lib/index-pack.jsView
@@ -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.jsonView
@@ -27,9 +27,9 @@
2727 "progress": "^1.1.8",
2828 "pull-buffered": "^0.3.1",
2929 "pull-cache": "^0.0.0",
3030 "pull-cat": "^1.1.8",
31- "pull-git-pack": "^0.1.1",
31+ "pull-git-pack": "^0.1.2",
3232 "pull-git-repo": "^0.2.2",
3333 "pull-hash": "^0.0.0",
3434 "pull-stream": "^3.1.0",
3535 "stream-to-pull-stream": "^1.6.6"
test/index-pack.jsView
@@ -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