cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/2] git commit: Add a shortlog command for aggregating commit counts
Date Fri, 06 Jun 2014 14:55:38 GMT
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 <agrieve@chromium.org>
Authored: Thu Jun 5 12:32:49 2014 -0400
Committer: Andrew Grieve <agrieve@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;


Mime
View raw message