You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/05/14 19:35:06 UTC

js commit: [all] Fail to package if git version is not available.

Updated Branches:
  refs/heads/master 3baed3b63 -> 82c2664c4


[all] Fail to package if git version is not available.

Also helps jake find git path on windows.


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

Branch: refs/heads/master
Commit: 82c2664c43c6f5058aec94cf99f25c38bc285900
Parents: 3baed3b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue May 14 13:34:26 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue May 14 13:34:26 2013 -0400

----------------------------------------------------------------------
 Jakefile |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/82c2664c/Jakefile
----------------------------------------------------------------------
diff --git a/Jakefile b/Jakefile
index bd1639e..0ac574c 100644
--- a/Jakefile
+++ b/Jakefile
@@ -61,10 +61,36 @@ function forEachFile(root, cbFile, cbDone) {
 }
 
 function computeGitVersion(callback) {
-    childProcess.exec('git describe --tags --long', function(err, stdout, stderr) {
+    var gitPath = 'git';
+    var args = 'describe --tags --long';
+    childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
+        var isWindows = process.platform.slice(0, 3) == 'win';
+        if (err && isWindows) {
+            gitPath = '"' + path.join(process.env['ProgramFiles'], 'Git', 'bin', 'git.exe') + '"';
+            childProcess.exec(gitPath + ' ' + args, function(err, stdout, stderr) {
+                if (err) {
+                    error(err);
+                } else {
+                    done(stdout);
+                }
+            });
+        } else if (err) {
+            error(err);
+        } else {
+            done(stdout);
+        }
+    });
+
+    function error(err) {
+        console.error('Git command failed: git ' + args);
+        console.error('Error: ' + err);
+        process.exit(1);
+    }
+
+    function done(stdout) {
         var version = stdout.trim().replace(/^2.5.0-.*?-/, 'dev-');
         callback(version);
-    });
+    };
 }
 
 desc("runs build");