pull-git-repo
Advanced tools
Comparing version 0.2.0 to 0.2.1
42
index.js
@@ -119,3 +119,3 @@ var buffered = require('pull-buffered') | ||
if (!name) | ||
return cb(new Error('Invalid name')) | ||
return cb(new Error('Invalid name \'' + name + '\'')) | ||
@@ -250,3 +250,3 @@ if (this.isCommitHash(name)) | ||
id: hash.toString('hex'), | ||
mode: s[0], | ||
mode: parseInt(s[0], 8), | ||
name: s[1] | ||
@@ -261,24 +261,26 @@ }) | ||
var readTree = this.readTree(rev) | ||
if (path.length === 0 || path === '/') | ||
return readTree | ||
var self = this | ||
path = (typeof path == 'string') ? path.split(/\/+/) : path.slice() | ||
return readNext(function next(cb) { | ||
if (path.length === 0) { | ||
// this is the directory the caller wants to read | ||
return cb(null, readTree) | ||
} | ||
var self = this | ||
return readNext(function (cb) { | ||
readTree(null, function next(err, file) { | ||
if (err) return cb(err) | ||
if (file.name !== path[0]) | ||
return readTree(null, next) | ||
if (file.mode !== '040000') | ||
return cb(new Error('Bad path')) | ||
// cancel reading current tree | ||
readTree(true, function (err) { | ||
// find the next file in the path | ||
pull( | ||
readTree, | ||
pull.filter(function (file) { | ||
return file.name === path[0] && file.mode == 040000 | ||
}), | ||
pull.take(1), | ||
pull.collect(function (err, files) { | ||
if (err) return cb(err) | ||
var file = files[0] | ||
if (!file) return cb(new Error('File \'' + path[0] + '\' not found')) | ||
path.shift() | ||
// start reading tree of found file | ||
readTree = self.readTree(file.hash) | ||
readTree = self.readTree(file.id) | ||
next(cb) | ||
}) | ||
}) | ||
) | ||
}) | ||
@@ -308,3 +310,3 @@ } | ||
read: object.read, | ||
mode: file.mode | ||
mode: parseInt(file.mode, 8) | ||
}) | ||
@@ -311,0 +313,0 @@ }) |
{ | ||
"name": "pull-git-repo", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "utility methods for git repos using pull streams", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14669
372