You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/05/23 19:38:57 UTC
[4/4] git commit: Fix handling of git revisions when fetching
dependencies
Fix handling of git revisions when fetching dependencies
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/4741f93c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/4741f93c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/4741f93c
Branch: refs/heads/master
Commit: 4741f93c2c988a18751f15e98c333b5708b4c66c
Parents: daec2d4
Author: Braden Shepherdson <br...@gmail.com>
Authored: Thu May 23 13:32:19 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Thu May 23 13:38:39 2013 -0400
----------------------------------------------------------------------
src/platforms/common.js | 2 -
src/util/plugins.js | 61 +++++++++++++++++++++--------------------
2 files changed, 31 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/4741f93c/src/platforms/common.js
----------------------------------------------------------------------
diff --git a/src/platforms/common.js b/src/platforms/common.js
index 09d68d3..0e602c1 100644
--- a/src/platforms/common.js
+++ b/src/platforms/common.js
@@ -13,14 +13,12 @@ module.exports = {
// helper for resolving target paths from plugin.xml into a cordova project
// throws File Exists
resolveTargetPath:function(project_dir, relative_path) {
- console.log('resolveTargetPath', project_dir, relative_path);
var full_path = path.resolve(project_dir, relative_path);
if (fs.existsSync(full_path)) throw new Error('"' + full_path + '" already exists!');
else return full_path;
},
// Many times we simply need to copy shit over, knowing if a source path doesnt exist or if a target path already exists
copyFile:function(plugin_dir, src, project_dir, dest) {
- console.log('copyFile', plugin_dir, src, project_dir, dest);
src = module.exports.resolveSrcPath(plugin_dir, src);
dest = module.exports.resolveTargetPath(project_dir, dest);
shell.mkdir('-p', path.dirname(dest));
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/4741f93c/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 4f532d4..07c5d95 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -39,40 +39,41 @@ module.exports = {
shell.rm('-rf', tmp_dir);
- var cmd = util.format('git clone "%s" "%s"', plugin_git_url, tmp_dir);
- shell.exec(cmd, {silent: true, async:true}, function(code, output) {
- if (code > 0) {
- var err = new Error('failed to get the plugin via git from URL '+ plugin_git_url + ', output: ' + output);
- if (callback) callback(err)
- else throw err;
- } else {
- console.log('Plugin "' + plugin_git_url + '" fetched.');
- // Check out the specified revision, if provided.
- if (git_ref) {
- var cmd = util.format('cd "%s" && git checkout "%s"', tmp_dir, git_ref);
- var result = shell.exec(cmd, { silent: true, async:false });
- if (result.code > 0) {
- var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '", output: ' + result.output);
- if (callback) callback(err);
- else throw err;
- }
+ shell.cd(path.dirname(tmp_dir));
+ var cmd = util.format('git clone "%s" "%s"', plugin_git_url, path.basename(tmp_dir));
+ var result = shell.exec(cmd, {silent: true, async:false});
+ if (result.code > 0) {
+ var err = new Error('failed to get the plugin via git from URL '+ plugin_git_url + ', output: ' + result.output);
+ if (callback) callback(err)
+ else throw err;
+ } else {
+ console.log('Plugin "' + plugin_git_url + '" fetched.');
+ // Check out the specified revision, if provided.
+ if (git_ref) {
+ var cmd = util.format('cd "%s" && git checkout "%s"', tmp_dir, git_ref);
+ var result = shell.exec(cmd, { silent: true, async:false });
+ if (result.code > 0) {
+ var err = new Error('failed to checkout git ref "' + git_ref + '" for plugin at git url "' + plugin_git_url + '", output: ' + result.output);
+ if (callback) callback(err);
+ else throw err;
}
+ console.log('Checked out ' + git_ref);
+ }
- // Read the plugin.xml file and extract the plugin's ID.
- tmp_dir = path.join(tmp_dir, subdir);
- // TODO: what if plugin.xml does not exist?
- var xml_file = path.join(tmp_dir, 'plugin.xml');
- var xml = xml_helpers.parseElementtreeSync(xml_file);
- var plugin_id = xml.getroot().attrib.id;
+ // Read the plugin.xml file and extract the plugin's ID.
+ tmp_dir = path.join(tmp_dir, subdir);
+ // TODO: what if plugin.xml does not exist?
+ var xml_file = path.join(tmp_dir, 'plugin.xml');
+ var xml = xml_helpers.parseElementtreeSync(xml_file);
+ var plugin_id = xml.getroot().attrib.id;
- // TODO: what if a plugin dependended on different subdirectories of the same plugin? this would fail.
- // should probably copy over entire plugin git repo contents into plugins_dir and handle subdir seperately during install.
- var plugin_dir = path.join(plugins_dir, plugin_id);
- shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
+ // TODO: what if a plugin dependended on different subdirectories of the same plugin? this would fail.
+ // should probably copy over entire plugin git repo contents into plugins_dir and handle subdir seperately during install.
+ var plugin_dir = path.join(plugins_dir, plugin_id);
+ shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
- if (callback) callback(null, plugin_dir);
- }
- });
+ if (callback) callback(null, plugin_dir);
+ }
}
};