Fix bug when targeting branches.

This commit is contained in:
André Cruz
2013-04-14 18:15:09 +01:00
parent c117ef3000
commit 8abd010d08
2 changed files with 4 additions and 6 deletions

View File

@@ -53,7 +53,6 @@ GitResolver.fetchRefs = function (source) {};
GitResolver.prototype._findResolution = function () {
var branches,
target,
self = this.constructor;
// Target is a range/version
@@ -86,16 +85,16 @@ GitResolver.prototype._findResolution = function () {
// Otherwise, assume target is a branch
return self.fetchHeads(this._sourcePath)
.then(function (heads) {
if (!heads[target]) {
if (!heads[this._target]) {
branches = Object.keys(heads);
throw createError('Branch "' + target + '" does not exist', 'ENORESTARGET', {
throw createError('Branch "' + this._target + '" does not exist', 'ENORESTARGET', {
details: !branches.length ?
'No branches found in "' + this._source + '"' :
'Available branches in "' + this._source + '" are: ' + branches.join(', ')
});
}
return { type: 'branch', branch: target, commit: heads[target] };
return { type: 'branch', branch: this._target, commit: heads[this._target] };
}.bind(this));
};