cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject [1/3] git commit: Add git ref support to fetch. Not used anywhere yet.
Date Tue, 14 May 2013 21:19:47 GMT
Updated Branches:
  refs/heads/dependencies 67f1f8b0c -> e75bdf6d2


Add git ref support to fetch. Not used anywhere yet.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/e2f1c879
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/e2f1c879
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/e2f1c879

Branch: refs/heads/dependencies
Commit: e2f1c87939d1c0d13e6370cf0f752ce00285870e
Parents: 14eed99
Author: Braden Shepherdson <braden.shepherdson@gmail.com>
Authored: Tue May 14 17:10:50 2013 -0400
Committer: Braden Shepherdson <braden.shepherdson@gmail.com>
Committed: Tue May 14 17:10:50 2013 -0400

----------------------------------------------------------------------
 spec/fetch.spec.js       |   10 +++++++++-
 src/fetch.js             |    4 ++--
 src/install.js           |    3 ++-
 src/util/dependencies.js |    3 ++-
 src/util/plugins.js      |   12 +++++++++++-
 5 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e2f1c879/spec/fetch.spec.js
----------------------------------------------------------------------
diff --git a/spec/fetch.spec.js b/spec/fetch.spec.js
index 8f7c678..79afaa4 100644
--- a/spec/fetch.spec.js
+++ b/spec/fetch.spec.js
@@ -42,7 +42,15 @@ describe('fetch', function() {
             var url = "https://github.com/bobeast/GAPlugin.git";
             var dir = 'fakeSubDir';
             fetch(url, temp, false, dir);
-            expect(s).toHaveBeenCalledWith(url, temp, dir, undefined);
+            expect(s).toHaveBeenCalledWith(url, temp, dir, undefined, undefined);
+        });
+        it('should call clonePluginGitRepo with subdir and git ref if applicable', function()
{
+            var s = spyOn(plugins, 'clonePluginGitRepo');
+            var url = "https://github.com/bobeast/GAPlugin.git";
+            var dir = 'fakeSubDir';
+            var ref = 'fakeGitRef';
+            fetch(url, temp, false, dir, ref);
+            expect(s).toHaveBeenCalledWith(url, temp, dir, ref, undefined);
         });
         it('should throw if used with url and `link` param', function() {
             expect(function() {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e2f1c879/src/fetch.js
----------------------------------------------------------------------
diff --git a/src/fetch.js b/src/fetch.js
index 73bf4e2..a222af6 100644
--- a/src/fetch.js
+++ b/src/fetch.js
@@ -4,7 +4,7 @@ var shell   = require('shelljs'),
     xml_helpers = require('./util/xml-helpers'),
     path    = require('path');
 
-module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, callback) {
+module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir, git_ref, callback)
{
     // Ensure the containing directory exists.
     shell.mkdir('-p', plugins_dir);
 
@@ -17,7 +17,7 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, subdir,
cal
             if (callback) callback(err);
             else throw err;
         } else {
-            plugins.clonePluginGitRepo(plugin_dir, plugins_dir, subdir, callback);
+            plugins.clonePluginGitRepo(plugin_dir, plugins_dir, subdir, git_ref, callback);
         }
     } else {
         // Copy from the local filesystem.

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e2f1c879/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 37d789c..c3ec3bc 100644
--- a/src/install.js
+++ b/src/install.js
@@ -21,7 +21,8 @@ module.exports = function installPlugin(platform, project_dir, name, plugins_dir
     // Check that the plugin has already been fetched.
     if (!fs.existsSync(plugin_dir)) {
         // if plugin doesnt exist, use fetch to get it.
-        require('../plugman').fetch(name, plugins_dir, false, '.', function(err, plugin_dir)
{
+        // TODO: Actual value for git_ref.
+        require('../plugman').fetch(name, plugins_dir, false, '.', undefined /* git_ref */,
function(err, plugin_dir) {
             if (err) {
                 callback(err);
             } else {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e2f1c879/src/util/dependencies.js
----------------------------------------------------------------------
diff --git a/src/util/dependencies.js b/src/util/dependencies.js
index 9f7a594..5608249 100644
--- a/src/util/dependencies.js
+++ b/src/util/dependencies.js
@@ -49,7 +49,8 @@ exports.installAll = function(platform, project_dir, name, plugins_dir,
cli_vari
             }
 
             console.log('Fetching dependency ' + dep.attrib.id);
-            fetch(dep.attrib.url, plugins_dir, false /* no link */, subdir, doInstall);
+            // TODO: Actual value for git_ref.
+            fetch(dep.attrib.url, plugins_dir, false /* no link */, subdir, undefined /*
git_ref */, doInstall);
         }
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/e2f1c879/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index ff9cace..f570026 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -30,7 +30,7 @@ var http = require('http'),
 module.exports = {
     searchAndReplace:require('./search-and-replace'),
     // Fetches plugin information from remote server
-    clonePluginGitRepo:function(plugin_git_url, plugins_dir, subdir, callback) {
+    clonePluginGitRepo:function(plugin_git_url, plugins_dir, subdir, git_ref, callback) {
         if(!shell.which('git')) {
             var err = new Error('git command line is not installed');
             if (callback) callback(err);
@@ -46,6 +46,16 @@ module.exports = {
                 if (callback) callback(err)
                 else throw err;
             } else {
+                // Check out the specified revision, if provided.
+                if (git_ref) {
+                    var result = shell.exec(util.format('git checkout "%s"', git_ref), {
silent: true });
+                    if (result.code > 0) {
+                        var err = new Error('failed to checkout git ref "' + git_ref + '"');
+                        if (callback) callback(err);
+                        else throw err;
+                    }
+                }
+
                 // 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?


Mime
View raw message