pull-git-repo
Advanced tools
Comparing version 0.2.5 to 0.3.0
63
index.js
@@ -30,2 +30,5 @@ var buffered = require('pull-buffered') | ||
if (repo.upstream) | ||
Repo(repo.upstream) | ||
return repo | ||
@@ -204,3 +207,3 @@ } | ||
R.isCommitHash = function (str) { | ||
return /[0-9a-f]{20}/.test(str) | ||
return /^[0-9a-f]{40}$/.test(str) | ||
} | ||
@@ -277,11 +280,9 @@ | ||
R.getCommitParsed = function (rev, cb) { | ||
this.getCommit(rev, function (err, object, hash) { | ||
this.getCommit(rev, function (err, object) { | ||
if (err) return cb(err) | ||
Repo.getCommitParsed(object, hash, cb) | ||
Repo.getCommitParsed(object, cb) | ||
}) | ||
} | ||
Repo.getCommitParsed = function (object, hash, cb) { | ||
if (!cb && typeof hash == 'function') | ||
cb = hash, hash = null | ||
Repo.getCommitParsed = function (object, cb) { | ||
var commit = { | ||
@@ -310,2 +311,17 @@ parents: [], | ||
Repo.getTagParsed = function (object, cb) { | ||
var tag = { | ||
tagger: {}, | ||
body: '' | ||
} | ||
return pull( | ||
Repo.parseCommitOrTag(object), | ||
pull.drain(function (field) { | ||
tag[field.name] = field.value | ||
}, function (err) { | ||
cb(err, tag) | ||
}) | ||
) | ||
} | ||
R.getTree = function (ref, cb) { | ||
@@ -477,3 +493,3 @@ var self = this | ||
read(null, function next(end, pack) { | ||
if (end) return cb(new Error('Object ' + hash + ' not found in pack')) | ||
if (end) return cb() | ||
self.getPackIndexCached(pack.idxId, function (err, idx) { | ||
@@ -506,2 +522,3 @@ if (err) return cb(err) | ||
if (err) return cb(err) | ||
if (!offset) return cb() | ||
self.getPackfileCached(offset.packId, function (err, bufs) { | ||
@@ -580,2 +597,3 @@ if (err) return cb(err) | ||
R.getObjectFromAny = function (hash, cb) { | ||
var self = this | ||
this.getObject(hash, function (err, obj) { | ||
@@ -585,13 +603,32 @@ if (obj) | ||
else | ||
this.getObjectFromPack(hash, cb) | ||
}.bind(this)) | ||
self.getObjectFromPack(hash, function (err, obj) { | ||
if (err) | ||
cb(err, obj) | ||
else if (obj) | ||
cb(null, obj) | ||
else if (self.upstream) | ||
self.upstream.getObjectFromAny(hash, cb) | ||
else | ||
cb(new NotFoundError('Object ' + hash + ' not found in repo')) | ||
}) | ||
}) | ||
} | ||
R.hasObjectFromAny = function (hash, cb) { | ||
var self = this | ||
this.hasObject(hash, function (err, has) { | ||
if (has) | ||
cb(null, true) | ||
if (err || has) | ||
cb(err, has) | ||
else | ||
this.hasObjectFromPack(hash, cb) | ||
}.bind(this)) | ||
self.hasObjectFromPack(hash, function (err, has) { | ||
if (err) | ||
cb(err, has) | ||
else if (has) | ||
cb(null, has) | ||
else if (self.upstream) | ||
self.upstream.hasObjectFromAny(hash, cb) | ||
else | ||
cb(null, false) | ||
}) | ||
}) | ||
} |
{ | ||
"name": "pull-git-repo", | ||
"version": "0.2.5", | ||
"version": "0.3.0", | ||
"description": "utility methods for git repos using pull streams", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,3 +14,3 @@ # pull-git-repo | ||
#### `Repo.parseCommitOrTag(object, id): source({name, value})` | ||
#### `Repo.parseCommitOrTag(object): source({name, value})` | ||
@@ -94,3 +94,3 @@ Read a git object and transform it into a stream of `{name, value}` properties, | ||
#### `repo.getCommitParsed(rev[, hash], cb(err, commit))` | ||
#### `repo.getCommitParsed(rev, cb(err, commit))` | ||
@@ -140,2 +140,14 @@ Get a commit buffered and parsed into a JSON object | ||
#### `Repo.getTagParsed(object, cb(err, tag))` | ||
Read a tag object and parse it into a JSON object | ||
- `tag.id`: ID of the tag | ||
- `tag.object`: ID of the tagged object | ||
- `tag.type`: type of the tagged object | ||
- `tag.tagger`: `user` object for info about the creator of the tag | ||
- `tag.title`: first line of the tag message | ||
- `tag.body`: text from the tag message following the first line and an | ||
optional blank line | ||
#### `repo.getFile(rev, path, cb(err, {length, mode, read)` | ||
@@ -142,0 +154,0 @@ |
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
23112
630
172