mirror of
https://github.com/bower/bower.git
synced 2026-02-11 22:44:58 -05:00
Add some more tests and fix some issues.
This commit is contained in:
@@ -19,19 +19,7 @@ mout.object.mixIn(GitFsResolver, GitResolver);
|
||||
|
||||
// -----------------
|
||||
|
||||
GitFsResolver.prototype._resolveSelf = function () {
|
||||
return this._findResolution()
|
||||
.then(this._readJson.bind(this, this._source))
|
||||
.then(this._copy.bind(this))
|
||||
.then(this._checkout.bind(this))
|
||||
.then(this._cleanup.bind(this));
|
||||
};
|
||||
|
||||
// -----------------
|
||||
|
||||
GitFsResolver.prototype._copy = function (meta) {
|
||||
var ignore = meta.ignore;
|
||||
|
||||
GitFsResolver.prototype._copy = function () {
|
||||
// Copy folder permissions
|
||||
return Q.nfcall(fs.stat, this._source)
|
||||
.then(function (stat) {
|
||||
@@ -39,10 +27,7 @@ GitFsResolver.prototype._copy = function (meta) {
|
||||
}.bind(this))
|
||||
// Copy folder contents
|
||||
.then(function () {
|
||||
return Q.nfcall(ncp, this._source, this._tempDir, {
|
||||
// Don't copy ignored files
|
||||
filter: ignore && ignore.length ? this._createIgnoreFilter(ignore) : null
|
||||
});
|
||||
return Q.nfcall(ncp, this._source, this._tempDir);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
@@ -50,8 +35,12 @@ GitFsResolver.prototype._copy = function (meta) {
|
||||
GitFsResolver.prototype._checkout = function () {
|
||||
var resolution = this._resolution;
|
||||
|
||||
// Checkout resolution
|
||||
return cmd('git', ['checkout', '-f', resolution.tag || resolution.branch || resolution.commit], { cwd: this._tempDir })
|
||||
// The checkout process could be similar to the GitRemoteResolver by prepending file:// to the source
|
||||
// But from my performance measures, it's faster to copy the folder and just checkout in there
|
||||
|
||||
// Copy files to the temporary directory first
|
||||
return this._copy()
|
||||
.then(cmd.bind(cmd, 'git', ['checkout', '-f', resolution.tag || resolution.branch || resolution.commit], { cwd: this._tempDir }))
|
||||
// Cleanup unstagged files
|
||||
.then(cmd.bind(cmd, 'git', ['clean', '-f', '-d'], { cwd: this._tempDir }));
|
||||
};
|
||||
@@ -67,7 +56,10 @@ GitFsResolver.fetchRefs = function (source) {
|
||||
return cmd('git', ['show-ref', '--tags', '--heads'], { cwd : source })
|
||||
.then(function (stdout) {
|
||||
// Make them an array
|
||||
var refs = stdout.toString().trim().split('\n');
|
||||
var refs = stdout.toString()
|
||||
.trim() // Trim trailing and leading spaces
|
||||
.replace(/[\t ]+/g, ' ') // Standardize spaces (some git versions make tabs, other spaces)
|
||||
.split(/\r?\n/); // Split lines into an array
|
||||
|
||||
this._refs = this._refs || {};
|
||||
return this._refs[source] = refs;
|
||||
|
||||
@@ -40,7 +40,10 @@ GitRemoteResolver.fetchRefs = function (source) {
|
||||
return cmd('git', ['ls-remote', '--tags', '--heads', source])
|
||||
.then(function (stdout) {
|
||||
// Make them an array
|
||||
var refs = stdout.toString().trim().split('\n');
|
||||
var refs = stdout.toString()
|
||||
.trim() // Trim trailing and leading spaces
|
||||
.replace(/[\t ]+/g, ' ') // Standardize spaces (some git versions make tabs, other spaces)
|
||||
.split(/\r?\n/); // Split lines into an array
|
||||
|
||||
this._refs = this._refs || {};
|
||||
return this._refs[source] = refs;
|
||||
|
||||
@@ -23,8 +23,13 @@ util.inherits(GitResolver, Resolver);
|
||||
|
||||
GitResolver.prototype._resolveSelf = function () {
|
||||
return this._findResolution()
|
||||
.then(this._checkout.bind(this))
|
||||
.then(this._cleanup.bind(this));
|
||||
.then(function () {
|
||||
return this._checkout()
|
||||
// Always run cleanup after checkout to ensure that .git is removed!
|
||||
// If it's not removed, problems might arrise when the "tmp" module attemps
|
||||
// to delete the temporary folder
|
||||
.fin(this._cleanup.bind(this));
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
GitResolver.prototype.hasNew = function (canonicalPkg) {
|
||||
|
||||
Reference in New Issue
Block a user