Skip to content

Commit

Permalink
Close GH-819: Fix resolutions not working properly when resolving to …
Browse files Browse the repository at this point in the history
…branches, closes #818.. Fixes #818
  • Loading branch information
satazor committed Aug 28, 2013
1 parent 742ef58 commit eb9dcce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
16 changes: 14 additions & 2 deletions lib/core/Manager.js
Expand Up @@ -117,6 +117,11 @@ Manager.prototype.install = function () {
return Q.reject(createError('Already working', 'EWORKING'));
}

// If nothing to install, skip the code bellow
if (mout.lang.isEmpty(that._dissected)) {
return Q.resolve({});
}

componentsDir = path.join(this._config.cwd, this._config.directory);
return Q.nfcall(mkdirp, componentsDir)
.then(function () {
Expand Down Expand Up @@ -634,14 +639,21 @@ Manager.prototype._electSuitable = function (name, semvers, nonSemvers) {
});

if (resolution && !unresolvable) {
suitable = -1;

// Range resolution
if (semver.validRange(resolution)) {
suitable = mout.array.findIndex(picks, function (pick) {
return pick.pkgMeta.version &&
semver.satisfies(pick.pkgMeta.version, resolution);
});
} else {
}

// Exact match resolution
if (suitable === -1) {
suitable = mout.array.findIndex(picks, function (pick) {
return pick.pkgMeta._release === resolution;
return pick.target === resolution ||
pick.pkgMeta._release === resolution;
});
}

Expand Down
9 changes: 7 additions & 2 deletions lib/core/Project.js
Expand Up @@ -774,8 +774,13 @@ Project.prototype._restoreNode = function (node, flattened, jsonKey) {
}

// Check if source changed, marking as different if it did
originalSource = mout.object.get(local, 'pkgMeta._originalSource');
restored.different = originalSource && originalSource !== json.source;
// We only do this for direct root dependencies that are compatible
if (node.root && compatible) {
originalSource = mout.object.get(local, 'pkgMeta._originalSource');
if (originalSource && originalSource !== json.source) {
restored.different = true;
}
}
}

// Cross reference
Expand Down
7 changes: 5 additions & 2 deletions lib/core/resolvers/GitResolver.js
Expand Up @@ -222,8 +222,11 @@ GitResolver.prototype._savePkgMeta = function (meta) {
delete meta.version;
}

// Save version/commit/branch/tag in the release
meta._release = version || this._resolution.tag || this._resolution.commit.substr(0, 10);
// Save version/tag//branch/commit in the release
meta._release = version ||
this._resolution.tag ||
this._resolution.branch ||
this._resolution.commit.substr(0, 10);

// Save resolution to be used in hasNew later
meta._resolution = this._resolution;
Expand Down

0 comments on commit eb9dcce

Please sign in to comment.