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/10/06 22:08:04 UTC

git commit: Add --user and --cherry-picks flags to last-week command

Repository: cordova-coho
Updated Branches:
  refs/heads/master 0bcba2759 -> 7c1e9e3e2


Add --user and --cherry-picks flags to last-week command


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

Branch: refs/heads/master
Commit: 7c1e9e3e23854186849ce762702d195c941b6519
Parents: 0bcba27
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Oct 6 16:07:40 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Oct 6 16:07:40 2014 -0400

----------------------------------------------------------------------
 src/last-week.js | 46 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/7c1e9e3e/src/last-week.js
----------------------------------------------------------------------
diff --git a/src/last-week.js b/src/last-week.js
index 2d174f6..172fdc3 100644
--- a/src/last-week.js
+++ b/src/last-week.js
@@ -25,13 +25,29 @@ var flagutil = require('./flagutil');
 var repoutil = require('./repoutil');
 
 module.exports = function*() {
+    var meEmail = yield executil.execHelper(executil.ARGS('git config user.email'), true);
     var opt = flagutil.registerRepoFlag(optimist);
-    opt = flagutil.registerHelpFlag(opt);
-    opt.usage('Shows formatted git log for changes in the past 7 days.\n' +
-              '\n' +
-              'Usage: $0 last-week [--repo=ios] [--me] [--days=7]\n' +
-              '    --me: Show only your commits\n' +
-              '    --days=n: Show commits from the past n days');
+    opt = flagutil.registerHelpFlag(opt)
+        .options('me', {
+                      desc: 'Show only your commits. Short for --user=' + meEmail + ' --cherry-picks=false',
+                      type: 'boolean'
+                   })
+        .options('cherry-picks', {
+                      desc: 'Show changes that you authored, even if you didn\'t commit them',
+                      type: 'boolean',
+                      default: true
+                   })
+        .options('user', {
+                      desc: 'Show commits for the given user (substring match)',
+                      type: 'string'
+                   })
+        .options('days', {
+                      desc: 'Show history for this many days instead of past week.',
+                      type: 'number'
+                   })
+        .usage('Shows formatted git log for changes in the past 7 days.\n' +
+               '\n' +
+               'Usage: $0 last-week [--repo=ios] [--me] [--days=7]');
     argv = opt.argv;
 
     if (argv.h) {
@@ -39,22 +55,30 @@ module.exports = function*() {
         process.exit(1);
     }
     var repos = flagutil.computeReposFromFlag(argv.r);
-    var filterByEmail = !!argv.me;
+    var filterByEmail = !!argv.me || !! argv.user;
     var days = argv.days || 7;
-    var userEmail = filterByEmail && (yield executil.execHelper(executil.ARGS('git config user.email'), true));
+    var userEmail = filterByEmail && (argv.user || meEmail);
+    var showCherryPicks = !argv.me && argv['cherry-picks'];
     var commitCount = 0;
     var pullRequestCount = 0;
 
     var cmd = executil.ARGS('git log --no-merges --date=short --all-match --fixed-strings');
     if (filterByEmail) {
-        cmd.push('--committer=' + userEmail, '--author=' + userEmail);
+        cmd.push('--author=' + userEmail);
+        if (!showCherryPicks) {
+            cmd.push('--committer=' + userEmail);
+        }
     }
 
     apputil.print('Running command: ' + cmd.join(' ') + ' --format="$REPO_NAME %s" --since="' + days + ' days ago"');
     yield repoutil.forEachRepo(repos, function*(repo) {
         var repoName = repo.id + new Array(Math.max(0, 20 - repo.id.length + 1)).join(' ');
-        var output = yield executil.execHelper(cmd.concat(['--format=' + repoName + ' %cd %s',
-            '--since=' + days + ' days ago']), true);
+        var format = '--format=' + repoName;
+        if (!filterByEmail) {
+            format += ' %an - ';
+        }
+        format += '%cd %s';
+        var output = yield executil.execHelper(cmd.concat([format, '--since=' + days + ' days ago']), true);
         if (output) {
             console.log(output);
             commitCount += output.split('\n').length;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org