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 2014/04/24 17:31:10 UTC

[1/2] git commit: for-each into its own module

Repository: cordova-coho
Updated Branches:
  refs/heads/master faddf4526 -> c41020ff4


for-each into its own module


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

Branch: refs/heads/master
Commit: 4bb3f9e689bbee01a793745effb3921a60e9548c
Parents: faddf45
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 24 11:18:16 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 24 11:18:16 2014 -0400

----------------------------------------------------------------------
 src/for-each.js | 45 +++++++++++++++++++++++++++++++++++++++++++++
 src/main.js     | 24 ++----------------------
 2 files changed, 47 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/4bb3f9e6/src/for-each.js
----------------------------------------------------------------------
diff --git a/src/for-each.js b/src/for-each.js
new file mode 100644
index 0000000..fcea16e
--- /dev/null
+++ b/src/for-each.js
@@ -0,0 +1,45 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var optimist = require('optimist');
+var path = require('path');
+var executil = require('./executil');
+var flagutil = require('./flagutil');
+var repoutil = require('./repoutil');
+
+module.exports = function*(argv) {
+    var opt = flagutil.registerRepoFlag(optimist)
+    opt = flagutil.registerHelpFlag(opt);
+    var argv = opt
+        .usage('Performs the supplied shell command in each repo directory.\n' +
+               '\n' +
+               'Usage: $0 foreach "shell command"')
+        .argv;
+
+    if (argv.h) {
+        optimist.showHelp();
+        process.exit(1);
+    }
+    var repos = flagutil.computeReposFromFlag(argv.r);
+    var cmd = argv._[1];
+    yield repoutil.forEachRepo(repos, function*(repo) {
+         yield executil.execHelper(argv._.slice(1), false, true);
+    });
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/4bb3f9e6/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index f4d6bc9..d84ff93 100644
--- a/src/main.js
+++ b/src/main.js
@@ -521,26 +521,6 @@ function *repoPushCommand(argv) {
     });
 }
 
-function *repoPerformShellCommand(argv) {
-    var opt = flagutil.registerRepoFlag(optimist)
-    opt = flagutil.registerHelpFlag(opt);
-    var argv = opt
-        .usage('Performs the supplied shell command in each repo directory.\n' +
-               '\n' +
-               'Usage: $0 foreach "shell command"')
-        .argv;
-
-    if (argv.h) {
-        optimist.showHelp();
-        process.exit(1);
-    }
-    var repos = flagutil.computeReposFromFlag(argv.r);
-    var cmd = argv._[1];
-    yield repoutil.forEachRepo(repos, function*(repo) {
-         yield executil.execHelper(argv._.slice(1), false, true);
-    });
-}
-
 function *repoUpdateCommand(argv) {
     var opt = flagutil.registerRepoFlag(optimist)
     var opt = opt
@@ -944,9 +924,9 @@ function main() {
             desc: 'Prints out git logs of things that happened last week.',
             entryPoint: require('./last-week')
         }, {
-            name: 'foreach',
+            name: 'for-each',
             desc: 'Runs a shell command in each repo.',
-            entryPoint: repoPerformShellCommand
+            entryPoint: require('./for-each')
         }, {
             name: 'list-release-urls',
             desc: 'List the apache git repo urls for release artifacts.',


[2/2] git commit: Move create-archive and verify-archive into their own modules

Posted by ag...@apache.org.
Move create-archive and verify-archive into their own modules


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

Branch: refs/heads/master
Commit: c41020ff49599a4d21a10fe9d248d841188847b3
Parents: 4bb3f9e
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 24 11:30:50 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 24 11:30:50 2014 -0400

----------------------------------------------------------------------
 src/create-verify-archive.js | 134 ++++++++++++++++++++++++++++++++++++++
 src/gitutil.js               |  26 ++++++++
 src/main.js                  | 115 ++------------------------------
 3 files changed, 164 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/c41020ff/src/create-verify-archive.js
----------------------------------------------------------------------
diff --git a/src/create-verify-archive.js b/src/create-verify-archive.js
new file mode 100644
index 0000000..e8fd5f1
--- /dev/null
+++ b/src/create-verify-archive.js
@@ -0,0 +1,134 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var optimist = require('optimist');
+var shelljs = require('shelljs');
+var fs = require('fs');
+var path = require('path');
+var apputil = require('./apputil');
+var executil = require('./executil');
+var flagutil = require('./flagutil');
+var gitutil = require('./gitutil');
+var repoutil = require('./repoutil');
+var print = apputil.print;
+
+exports.createCommand = function*(argv) {
+    var opt = flagutil.registerRepoFlag(optimist)
+    opt = opt
+        .options('tag', {
+            desc: 'The pre-existing tag to archive (defaults to newest tag on branch)'
+         })
+        .options('sign', {
+            desc: 'Whether to create .asc, .md5, .sha files (defaults to true)',
+            type: 'boolean',
+            default: true
+         })
+        .options('dest', {
+            desc: 'The directory to hold the resulting files.',
+            demand: true
+         });
+    opt = flagutil.registerHelpFlag(opt);
+    var argv = opt
+        .usage('Creates a .zip, .asc, .md5, .sha for a repo at a tag.\n' +
+               'Refer to https://wiki.apache.org/cordova/SetUpGpg for how to set up gpg\n' +
+               '\n' +
+               'Usage: $0 create-archive -r plugman -r cli --dest cordova-dist-dev/CB-1111')
+        .argv;
+
+    if (argv.h) {
+        optimist.showHelp();
+        process.exit(1);
+    }
+    var repos = flagutil.computeReposFromFlag(argv.r);
+
+    if (argv.sign && !shelljs.which('gpg')) {
+        apputil.fatal('gpg command not found on your PATH. Refer to https://wiki.apache.org/cordova/SetUpGpg');
+    }
+
+    var outDir = 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);
+
+        if(repo.id==='plugman'|| repo.id==='cli'){
+            var tgzname = yield executil.execHelper(executil.ARGS('npm pack'), true);
+            var outPath = path.join(absOutDir, 'cordova-' + tgzname);
+            shelljs.mv(tgzname, outPath);
+        }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));
+        }
+        if (argv.sign) {
+            yield executil.execHelper(executil.ARGS('gpg --armor --detach-sig --output', outPath + '.asc', outPath));
+            fs.writeFileSync(outPath + '.md5', (yield computeHash(outPath, 'MD5')) + '\n');
+            fs.writeFileSync(outPath + '.sha', (yield computeHash(outPath, 'SHA512')) + '\n');
+        }
+    });
+    print();
+    print('Archives created.');
+    print('Verify them using: coho verify-archive ' + path.join(outDir, '*.zip') + ' ' + path.join(outDir, '*.tgz'));
+}
+
+exports.verifyCommand = function*(argv) {
+    var opt = flagutil.registerRepoFlag(optimist)
+    opt = flagutil.registerHelpFlag(opt);
+    var argv = opt
+        .usage('Ensures the given .zip files match their neighbouring .asc, .md5, .sha files.\n' +
+               'Refer to https://wiki.apache.org/cordova/SetUpGpg for how to set up gpg\n' +
+               '\n' +
+               'Usage: $0 verify-archive a.zip b.zip c.zip')
+        .argv;
+
+    var zipPaths = argv._.slice(1);
+    if (argv.h || !zipPaths.length) {
+        optimist.showHelp();
+        process.exit(1);
+    }
+    if (!shelljs.which('gpg')) {
+        apputil.fatal('gpg command not found on your PATH. Refer to https://wiki.apache.org/cordova/SetUpGpg');
+    }
+
+    for (var i = 0; i < zipPaths.length; ++i) {
+        var zipPath = 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) {
+            apputil.fatal('MD5 does not match.');
+        }
+        var sha = yield computeHash(zipPath, 'SHA512');
+        if (extractHashFromOutput(fs.readFileSync(zipPath + '.sha', 'utf8')) !== sha) {
+            apputil.fatal('SHA512 does not match.');
+        }
+        print(zipPath + ' signature and hashes verified.');
+    }
+}
+
+function *computeHash(path, algo) {
+    print('Computing ' + algo + ' for: ' + path);
+    var result = yield executil.execHelper(executil.ARGS('gpg --print-md', algo, path), true);
+    return extractHashFromOutput(result);
+}
+
+function extractHashFromOutput(output) {
+    return output.replace(/.*?:/, '').replace(/\s*/g, '').toLowerCase();
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/c41020ff/src/gitutil.js
----------------------------------------------------------------------
diff --git a/src/gitutil.js b/src/gitutil.js
new file mode 100644
index 0000000..9a528c7
--- /dev/null
+++ b/src/gitutil.js
@@ -0,0 +1,26 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var path = require('path');
+var executil = require('./executil');
+
+exports.findMostRecentTag = function() {
+    return executil.execHelper(executil.ARGS('git describe --tags --abbrev=0 HEAD'), true);
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/c41020ff/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index d84ff93..714e68a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -23,6 +23,7 @@ var path = require('path');
 var flagutil = require('./flagutil');
 var apputil = require('./apputil');
 var executil = require('./executil');
+var gitutil = require('./gitutil');
 var repoutil = require('./repoutil');
 var print = apputil.print;
 try {
@@ -73,110 +74,6 @@ function createRepoUrl(repo) {
     return 'https://git-wip-us.apache.org/repos/asf/' + repo.repoName + '.git';
 }
 
-function *createArchiveCommand(argv) {
-    var opt = flagutil.registerRepoFlag(optimist)
-    opt = opt
-        .options('tag', {
-            desc: 'The pre-existing tag to archive (defaults to newest tag on branch)'
-         })
-        .options('sign', {
-            desc: 'Whether to create .asc, .md5, .sha files (defaults to true)',
-            type: 'boolean',
-            default: true
-         })
-        .options('dest', {
-            desc: 'The directory to hold the resulting files.',
-            demand: true
-         });
-    opt = flagutil.registerHelpFlag(opt);
-    var argv = opt
-        .usage('Creates a .zip, .asc, .md5, .sha for a repo at a tag.\n' +
-               'Refer to https://wiki.apache.org/cordova/SetUpGpg for how to set up gpg\n' +
-               '\n' +
-               'Usage: $0 create-archive -r plugman -r cli --dest cordova-dist-dev/CB-1111')
-        .argv;
-
-    if (argv.h) {
-        optimist.showHelp();
-        process.exit(1);
-    }
-    var repos = flagutil.computeReposFromFlag(argv.r);
-
-    if (argv.sign && !shjs.which('gpg')) {
-        apputil.fatal('gpg command not found on your PATH. Refer to https://wiki.apache.org/cordova/SetUpGpg');
-    }
-
-    var outDir = argv.dest;
-    shjs.mkdir('-p', outDir);
-    var absOutDir = path.resolve(outDir);
-
-    yield repoutil.forEachRepo(repos, function*(repo) {
-        var tag = argv.tag || (yield findMostRecentTag());
-        print('Creating archive of ' + repo.repoName + '@' + tag);
-
-        if(repo.id==='plugman'|| repo.id==='cli'){
-            var tgzname = yield executil.execHelper(executil.ARGS('npm pack'), true);
-            var outPath = path.join(absOutDir, 'cordova-' + tgzname);
-            shjs.mv(tgzname, outPath);
-        }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));
-        }
-        if (argv.sign) {
-            yield executil.execHelper(executil.ARGS('gpg --armor --detach-sig --output', outPath + '.asc', outPath));
-            fs.writeFileSync(outPath + '.md5', (yield computeHash(outPath, 'MD5')) + '\n');
-            fs.writeFileSync(outPath + '.sha', (yield computeHash(outPath, 'SHA512')) + '\n');
-        }
-    });
-    print();
-    print('Archives created.');
-    print('Verify them using: coho verify-archive ' + path.join(outDir, '*.zip') + ' ' + path.join(outDir, '*.tgz'));
-}
-
-function *computeHash(path, algo) {
-    print('Computing ' + algo + ' for: ' + path);
-    var result = yield executil.execHelper(executil.ARGS('gpg --print-md', algo, path), true);
-    return extractHashFromOutput(result);
-}
-
-function extractHashFromOutput(output) {
-    return output.replace(/.*?:/, '').replace(/\s*/g, '').toLowerCase();
-}
-
-function *verifyArchiveCommand(argv) {
-    var opt = flagutil.registerRepoFlag(optimist)
-    opt = flagutil.registerHelpFlag(opt);
-    var argv = opt
-        .usage('Ensures the given .zip files match their neighbouring .asc, .md5, .sha files.\n' +
-               'Refer to https://wiki.apache.org/cordova/SetUpGpg for how to set up gpg\n' +
-               '\n' +
-               'Usage: $0 verify-archive a.zip b.zip c.zip')
-        .argv;
-
-    var zipPaths = argv._.slice(1);
-    if (argv.h || !zipPaths.length) {
-        optimist.showHelp();
-        process.exit(1);
-    }
-    if (!shjs.which('gpg')) {
-        apputil.fatal('gpg command not found on your PATH. Refer to https://wiki.apache.org/cordova/SetUpGpg');
-    }
-
-    for (var i = 0; i < zipPaths.length; ++i) {
-        var zipPath = 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) {
-            apputil.fatal('MD5 does not match.');
-        }
-        var sha = yield computeHash(zipPath, 'SHA512');
-        if (extractHashFromOutput(fs.readFileSync(zipPath + '.sha', 'utf8')) !== sha) {
-            apputil.fatal('SHA512 does not match.');
-        }
-        print(zipPath + ' signature and hashes verified.');
-    }
-}
-
 function *printTagsCommand(argv) {
     var opt = flagutil.registerRepoFlag(optimist)
     opt = flagutil.registerHelpFlag(opt);
@@ -193,7 +90,7 @@ function *printTagsCommand(argv) {
     var repos = flagutil.computeReposFromFlag(argv.r);
 
     yield repoutil.forEachRepo(repos, function*(repo) {
-        var tag = yield findMostRecentTag();
+        var tag = yield gitutil.findMostRecentTag();
         var ref = yield executil.execHelper(executil.ARGS('git show-ref ' + tag), true);
         console.log('    ' + repo.repoName + ': ' + tag.replace(/^r/, '') + ' (' + ref.slice(0, 10) + ')');
     });
@@ -254,10 +151,6 @@ function *retrieveCurrentBranchName(allowDetached) {
     return match[1];
 }
 
-function findMostRecentTag() {
-    return executil.execHelper(executil.ARGS('git describe --tags --abbrev=0 HEAD'), true);
-}
-
 function retrieveCurrentTagName() {
     // This will return the tag name plus commit info it not directly at a tag.
     // That's fine since all users of this function are meant to use the result
@@ -910,11 +803,11 @@ function main() {
         }, {
             name: 'create-archive',
             desc: 'Zips up a tag, signs it, and adds checksum files.',
-            entryPoint: createArchiveCommand
+            entryPoint: require('./create-verify-archive').createCommand
         }, {
             name: 'verify-archive',
             desc: 'Checks that archives are properly signed and hashed.',
-            entryPoint: verifyArchiveCommand
+            entryPoint: require('./create-verify-archive').verifyCommand
         }, {
             name: 'print-tags',
             desc: 'Prints out tags & hashes for the given repos. Used in VOTE emails.',