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/06/06 16:55:38 UTC
[1/2] git commit: Add a shortlog command for aggregating commit counts
Repository: cordova-coho
Updated Branches:
refs/heads/master 70eba7c12 -> 181b2fa13
Add a shortlog command for aggregating commit counts
Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/20934b26
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/20934b26
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/20934b26
Branch: refs/heads/master
Commit: 20934b26b02b9f3c8105eac61ed28a182c1a552b
Parents: 70eba7c
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jun 5 12:32:49 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jun 5 12:33:10 2014 -0400
----------------------------------------------------------------------
src/main.js | 4 +++
src/shortlog.js | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/superspawn.js | 2 ++
3 files changed, 86 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/20934b26/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index e38f509..9025e75 100644
--- a/src/main.js
+++ b/src/main.js
@@ -98,6 +98,10 @@ module.exports = function() {
desc: 'Prints out git logs of things that happened last week.',
entryPoint: require('./last-week')
}, {
+ name: 'shortlog',
+ desc: 'A version of `git shortlog -s` aggregated across multiple repos.',
+ entryPoint: require('./shortlog')
+ }, {
name: 'for-each',
desc: 'Runs a shell command in each repo.',
entryPoint: require('./for-each')
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/20934b26/src/shortlog.js
----------------------------------------------------------------------
diff --git a/src/shortlog.js b/src/shortlog.js
new file mode 100644
index 0000000..b6e5589
--- /dev/null
+++ b/src/shortlog.js
@@ -0,0 +1,80 @@
+/*
+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*() {
+ var opt = flagutil.registerRepoFlag(optimist);
+ opt = flagutil.registerHelpFlag(opt);
+ opt.usage('A version of `git shortlog -s` aggregated across multiple repos.\n' +
+ '\n' +
+ 'Usage: $0 shortlog [--repo=ios] [--days=7] [--filter=regexp]\n' +
+ ' --filter: Sum up all commits that match this pattern\n' +
+ ' --days=n: Show commits from the past n days');
+ argv = opt.argv;
+
+ if (argv.h) {
+ optimist.showHelp();
+ process.exit(1);
+ }
+ var repos = flagutil.computeReposFromFlag(argv.r);
+ var emailFilter = argv.filter && new RegExp(argv.filter);
+ var days = argv.days || 7;
+
+ var resultsByAuthor = Object.create(null);
+ yield repoutil.forEachRepo(repos, function*(repo) {
+ var cmd = executil.ARGS('git shortlog -s -e --no-merges ', '--since=' + days + ' days ago');
+ var output = yield executil.execHelper(cmd, true);
+ if (output) {
+ output.split(/\n/).forEach(function(line) {
+ var m = /\s*(\d+).*?<(.*?)>/.exec(line);
+ var author = m[2];
+ var count = +m[1];
+ resultsByAuthor[author] = +(resultsByAuthor[author] || 0) + count;
+ });
+ }
+ });
+
+ var total = 0;
+ var filterTotal = 0;
+ var records = Object.keys(resultsByAuthor).map(function(author) {
+ var count = resultsByAuthor[author];
+ total += count;
+ if (emailFilter && emailFilter.exec(author)) {
+ filterTotal += count;
+ }
+ return {author:author, count:count};
+ });
+ records.sort(function(a,b) {
+ return b.count - a.count;
+ });
+
+ records.forEach(function(r) {
+ console.log(r.count + '\t' + r.author);
+ });
+ console.log();
+ if (emailFilter) {
+ console.log('Total that mathed filter: ' + filterTotal);
+ }
+ console.log('Total Commits: ' + total);
+}
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/20934b26/src/superspawn.js
----------------------------------------------------------------------
diff --git a/src/superspawn.js b/src/superspawn.js
index 0f1783c..1b9aa78 100644
--- a/src/superspawn.js
+++ b/src/superspawn.js
@@ -93,6 +93,8 @@ exports.spawn = function(cmd, args, opts) {
spawnOpts.stdio = 'ignore';
} else if (pipeOutput) {
spawnOpts.stdio = [process.stdin, 'pipe', process.stderr];
+ } else {
+ spawnOpts.stdio = [process.stdin, 'pipe', 'pipe'];
}
if (opts.cwd) {
spawnOpts.cwd = opts.cwd;
[2/2] git commit: Don't require commands that aren't being run
(speeds up gnode version)
Posted by ag...@apache.org.
Don't require commands that aren't being run (speeds up gnode version)
Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/181b2fa1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/181b2fa1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/181b2fa1
Branch: refs/heads/master
Commit: 181b2fa13a5069b98f343eaa5a79eef9d4ed9061
Parents: 20934b2
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Jun 6 10:55:00 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jun 6 10:55:00 2014 -0400
----------------------------------------------------------------------
src/main.js | 44 ++++++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/181b2fa1/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index 9025e75..90229ed 100644
--- a/src/main.js
+++ b/src/main.js
@@ -29,82 +29,90 @@ try {
}
var apputil = require('./apputil');
+function *lazyRequire(name, opt_prop) {
+ if (opt_prop) {
+ yield require(name)[opt_prop];
+ } else {
+ yield require(name);
+ }
+}
+
module.exports = function() {
var repoCommands = [
{
name: 'repo-clone',
desc: 'Clones git repositories into the current working directory.',
- entryPoint: require('./repo-clone')
+ entryPoint: lazyRequire('./repo-clone')
}, {
name: 'repo-update',
desc: 'Performs git pull --rebase on all specified repositories.',
- entryPoint: require('./repo-update')
+ entryPoint: lazyRequire('./repo-update')
}, {
name: 'repo-reset',
desc: 'Performs git reset --hard origin/$BRANCH and git clean -f -d on all specified repositories.',
- entryPoint: require('./repo-reset')
+ entryPoint: lazyRequire('./repo-reset')
}, {
name: 'repo-status',
desc: 'Lists changes that exist locally but have not yet been pushed.',
- entryPoint: require('./repo-status')
+ entryPoint: lazyRequire('./repo-status')
}, {
name: 'repo-push',
desc: 'Push changes that exist locally but have not yet been pushed.',
- entryPoint: require('./repo-push')
+ entryPoint: lazyRequire('./repo-push')
}, {
name: 'list-repos',
desc: 'Shows a list of valid values for the --repo flag.',
- entryPoint: require('./list-repos')
+ entryPoint: lazyRequire('./list-repos')
}];
var releaseCommands = [{
name: 'prepare-release-branch',
desc: 'Branches, updates JS, updates VERSION. Safe to run multiple times.',
- entryPoint: require('./cadance-release').prepareReleaseBranchCommand
+ entryPoint: lazyRequire('./cadance-release', 'prepareReleaseBranchCommand')
}, {
name: 'tag-release',
desc: 'Tags repos for a release.',
- entryPoint: require('./cadance-release').tagReleaseBranchCommand
+ entryPoint: lazyRequire('./cadance-release', 'tagReleaseBranchCommand')
}, {
name: 'audit-license-headers',
desc: 'Uses Apache RAT to look for missing license headers.',
- entryPoint: require('./audit-license-headers')
+ entryPoint: lazyRequire('./audit-license-headers')
}, {
name: 'create-release-bug',
desc: 'Creates a bug in JIRA for tracking the tasks involved in a new release',
- entryPoint: require('./create-release-bug')
+ entryPoint: lazyRequire('./create-release-bug')
}, {
name: 'create-archive',
desc: 'Zips up a tag, signs it, and adds checksum files.',
- entryPoint: require('./create-verify-archive').createCommand
+ entryPoint: lazyRequire('./create-verify-archive', 'createCommand')
}, {
name: 'verify-archive',
desc: 'Checks that archives are properly signed and hashed.',
- entryPoint: require('./create-verify-archive').verifyCommand
+ entryPoint: lazyRequire('./create-verify-archive', 'verifyCommand')
}, {
name: 'print-tags',
desc: 'Prints out tags & hashes for the given repos. Used in VOTE emails.',
- entryPoint: require('./print-tags')
+ entryPoint: lazyRequire('./print-tags')
}, {
name: 'list-release-urls',
desc: 'List the apache git repo urls for release artifacts.',
- entryPoint: require('./list-release-urls')
+ entryPoint: lazyRequire('./list-release-urls')
}];
var otherCommands = [{
name: 'list-pulls',
desc: 'Shows a list of GitHub pull requests for all specified repositories.',
- entryPoint: require('./list-pulls')
+ entryPoint: lazyRequire('./list-pulls')
}, {
name: 'last-week',
desc: 'Prints out git logs of things that happened last week.',
- entryPoint: require('./last-week')
+ entryPoint: lazyRequire('./last-week')
}, {
name: 'shortlog',
desc: 'A version of `git shortlog -s` aggregated across multiple repos.',
- entryPoint: require('./shortlog')
+ entryPoint: lazyRequire('./shortlog')
}, {
name: 'for-each',
desc: 'Runs a shell command in each repo.',
- entryPoint: require('./for-each')
+ entryPoint: lazyRequire('./for-each')
}
];
var commandMap = {};