cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] cordova-lib git commit: actually checkout git_ref because it may be a branch OR a commit SHA
Date Mon, 20 Jul 2015 22:33:11 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master bed6d3a20 -> 21fc9c01a


actually checkout git_ref because it may be a branch OR a commit SHA


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

Branch: refs/heads/master
Commit: 9af173a65281e9ea87fc6da3ee0b9f10bb8fec1c
Parents: bed6d3a
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Fri Jul 17 16:27:18 2015 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Fri Jul 17 16:27:18 2015 -0700

----------------------------------------------------------------------
 cordova-lib/src/gitclone.js | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9af173a6/cordova-lib/src/gitclone.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/gitclone.js b/cordova-lib/src/gitclone.js
index b977184..272db59 100644
--- a/cordova-lib/src/gitclone.js
+++ b/cordova-lib/src/gitclone.js
@@ -21,7 +21,6 @@ var  Q             = require('q'),
      shell         = require('shelljs'),
      events        = require('./events'),
      path          = require('path'),
-     semver        = require('semver'),
      superspawn    = require('./cordova/superspawn'),
      os            = require('os');
 
@@ -31,6 +30,7 @@ exports.clone = clone;
 //  clone_dir, if provided is the directory that git will clone into.
 //  if no clone_dir is supplied, a temp directory will be created and used by git.
 function clone(git_url, git_ref, clone_dir){
+    
     var needsGitCheckout = !!git_ref;
     if (!shell.which('git')) {
         return Q.reject(new Error('"git" command line tool is not installed: make sure it
is accessible on your PATH.'));
@@ -43,34 +43,26 @@ function clone(git_url, git_ref, clone_dir){
     }
     shell.rm('-rf', tmp_dir);
     shell.mkdir('-p', tmp_dir);
-
-    return superspawn.spawn('git', ['--version'])
-    .then(function(output) {
-        var gitVersion = /\d+\.\d+(\.\d+)?/.exec(output);
-        gitVersion = gitVersion ? gitVersion[0] : '1.0.0';
-        var cloneArgs = ['clone'];
-        if (semver.gte(gitVersion, '1.7.0')) {
-            if (git_ref) {
-                cloneArgs.push('--branch', git_ref);
-                needsGitCheckout = false;
-            }
-            if (semver.gte(gitVersion, '1.7.10')) {
-                cloneArgs.push('--single-branch');
-            }
-            cloneArgs.push('--depth=1');
-        }
-        cloneArgs.push('--', git_url, tmp_dir);
-        return superspawn.spawn('git', cloneArgs);
-    }).then(function() {
+    
+    var cloneArgs = ['clone'];
+    if(!needsGitCheckout) {
+        // only get depth of 1 if there is no branch/commit specified
+        cloneArgs.push('--depth=1');
+    }
+    cloneArgs.push(git_url, tmp_dir);
+    return superspawn.spawn('git', cloneArgs)
+    .then(function() {
         if (needsGitCheckout){
             return superspawn.spawn('git', ['checkout', git_ref], {
                 cwd: tmp_dir
             });
         }
-    }).then(function(){
+    })
+    .then(function(){
         events.emit('log', 'Repository "' + git_url + '" checked out to git ref "' + (git_ref
|| 'master') + '".');
         return tmp_dir;
-    }).fail(function (err) {
+    })
+    .fail(function (err) {
         shell.rm('-rf', tmp_dir);
         return Q.reject(err);
     });


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message