cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/3] git commit: Properly resolve relative paths given on command-line
Date Mon, 09 Jun 2014 19:07:12 GMT
Repository: cordova-coho
Updated Branches:
  refs/heads/master 41fc084fe -> a2512a280


Properly resolve relative paths given on command-line


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

Branch: refs/heads/master
Commit: a2512a280bcb879104f56039e94f4a230ae4f366
Parents: ce0f6d2
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Jun 9 15:06:32 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Jun 9 15:07:00 2014 -0400

----------------------------------------------------------------------
 src/apputil.js               |  9 +++++++--
 src/create-verify-archive.js | 16 +++++++++++-----
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/a2512a28/src/apputil.js
----------------------------------------------------------------------
diff --git a/src/apputil.js b/src/apputil.js
index 2f72890..c729d81 100644
--- a/src/apputil.js
+++ b/src/apputil.js
@@ -21,13 +21,18 @@ var path = require('path');
 var chalk = require('chalk');
 
 var origWorkingDir = process.cwd();
+var baseWorkingDir = origWorkingDir;
+
+exports.resolveUserSpecifiedPath = function(p) {
+    return path.resolve(origWorkingDir, p);
+};
 
 exports.initWorkingDir = function(chdir) {
     var curDir = path.resolve(origWorkingDir);
     var newDir = chdir ? path.resolve(path.join(__dirname), '..', '..') : curDir;
     if (curDir != newDir) {
         process.chdir(newDir);
-        origWorkingDir = newDir;
+        baseWorkingDir = newDir;
     }
     console.log('Running from ' + newDir);
 }
@@ -41,7 +46,7 @@ exports.print = function() {
     var newArgs = Array.prototype.slice.call(arguments);
     // Prefix any prints() to distinguish them from command output.
     if (newArgs.length > 1 || newArgs[0]) {
-        var curDir = path.relative(origWorkingDir, process.cwd());
+        var curDir = path.relative(baseWorkingDir, process.cwd());
         curDir = curDir ? curDir + '/' : './';
         var banner = ' =';
         var PREFIX_LEN = 30;

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/a2512a28/src/create-verify-archive.js
----------------------------------------------------------------------
diff --git a/src/create-verify-archive.js b/src/create-verify-archive.js
index e8fd5f1..602132d 100644
--- a/src/create-verify-archive.js
+++ b/src/create-verify-archive.js
@@ -19,6 +19,7 @@ under the License.
 
 var optimist = require('optimist');
 var shelljs = require('shelljs');
+var chalk = require('chalk');
 var fs = require('fs');
 var path = require('path');
 var apputil = require('./apputil');
@@ -61,19 +62,23 @@ exports.createCommand = function*(argv) {
         apputil.fatal('gpg command not found on your PATH. Refer to https://wiki.apache.org/cordova/SetUpGpg');
     }
 
-    var outDir = argv.dest;
+    var outDir = apputil.resolveUserSpecifiedPath(argv.dest);
     shelljs.mkdir('-p', outDir);
     var absOutDir = path.resolve(outDir);
 
     yield repoutil.forEachRepo(repos, function*(repo) {
         var tag = argv.tag || (yield gitutil.findMostRecentTag());
         print('Creating archive of ' + repo.repoName + '@' + tag);
+        yield gitutil.gitCheckout('master');
 
-        if(repo.id==='plugman'|| repo.id==='cli'){
+        if (repo.id==='plugman'|| repo.id==='cli') {
+            if (yield gitutil.pendingChangesExist()) {
+                apputil.fatal('Aborting because pending changes exist in ' + repo.repoName);
+            }
             var tgzname = yield executil.execHelper(executil.ARGS('npm pack'), true);
             var outPath = path.join(absOutDir, 'cordova-' + tgzname);
             shelljs.mv(tgzname, outPath);
-        }else{
+        } else {
             var outPath = path.join(absOutDir, repo.repoName + '-' + tag + '.zip');
             yield executil.execHelper(executil.ARGS('git archive --format zip --prefix '
+ repo.repoName + '/ -o ', outPath, tag));
         }
@@ -108,7 +113,7 @@ exports.verifyCommand = function*(argv) {
     }
 
     for (var i = 0; i < zipPaths.length; ++i) {
-        var zipPath = zipPaths[i];
+        var zipPath = apputil.resolveUserSpecifiedPath(zipPaths[i]);
         yield executil.execHelper(executil.ARGS('gpg --verify', zipPath + '.asc', zipPath));
         var md5 = yield computeHash(zipPath, 'MD5');
         if (extractHashFromOutput(fs.readFileSync(zipPath + '.md5', 'utf8')) !== md5) {
@@ -118,8 +123,9 @@ exports.verifyCommand = function*(argv) {
         if (extractHashFromOutput(fs.readFileSync(zipPath + '.sha', 'utf8')) !== sha) {
             apputil.fatal('SHA512 does not match.');
         }
-        print(zipPath + ' signature and hashes verified.');
+        print(zipPath + chalk.green(' signature and hashes verified.'));
     }
+    print(chalk.green('Verified ' + zipPaths.length + ' signatures and hashes.'));
 }
 
 function *computeHash(path, algo) {


Mime
View raw message