You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2016/12/11 20:48:47 UTC

cordova-coho git commit: Added --override-date and --last-two-tag options for update-release-notes. Modified gitUtil.findMostRecentTag to return an Array, instead of a string.

Repository: cordova-coho
Updated Branches:
  refs/heads/master e75e7d90f -> 439db5d00


Added --override-date and --last-two-tag options for update-release-notes. Modified gitUtil.findMostRecentTag to return an Array, instead of a string.


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

Branch: refs/heads/master
Commit: 439db5d00aa62fddbce2e272599b393e42a65889
Parents: e75e7d9
Author: Shazron Abdullah <sh...@apache.org>
Authored: Sun Dec 11 12:48:43 2016 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Sun Dec 11 12:48:43 2016 -0800

----------------------------------------------------------------------
 src/create-verify-archive.js |  2 +-
 src/gitutil.js               | 20 ++++++++++++++++++--
 src/print-tags.js            |  2 +-
 src/update-release-notes.js  | 33 +++++++++++++++++++++++----------
 4 files changed, 43 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/439db5d0/src/create-verify-archive.js
----------------------------------------------------------------------
diff --git a/src/create-verify-archive.js b/src/create-verify-archive.js
index e4485ff..599c15b 100644
--- a/src/create-verify-archive.js
+++ b/src/create-verify-archive.js
@@ -82,7 +82,7 @@ exports.createCommand = function*(argv) {
             yield checkLineEndings(repo);
         }
 
-        var tag = argv.tag || (yield gitutil.findMostRecentTag(repo.versionPrefix));
+        var tag = argv.tag || (yield gitutil.findMostRecentTag(repo.versionPrefix))[0];
         if (!tag) {
             apputil.fatal('Could not find most recent tag. Try running with --tag');
         }

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/439db5d0/src/gitutil.js
----------------------------------------------------------------------
diff --git a/src/gitutil.js b/src/gitutil.js
index 5aae6f2..9921c70 100644
--- a/src/gitutil.js
+++ b/src/gitutil.js
@@ -26,14 +26,15 @@ var semver = require('semver');
  * Returns the greatest semver-looking tag in the repo. If prefix is specified, only looks at tags that start with
  * 'prefix-' (this allows for multiple modules in the same repo).
  * @param {string} [prefix] - An optional prefix to filter tags.
- * @returns {string} - the most recent tag, or null if no version tags are found.
+ * @returns {Array} - the most recent tag as as the 0th index in an array (with the second recent as the next index), or null if no version tags are found.
  * ignores r tags in plugins
  */
 exports.findMostRecentTag = function*(prefix) {
     prefix = prefix && prefix + "-";
     var finalBest;
+    var lastBest;
 
-    return (yield executil.execHelper(executil.ARGS('git tag --list'), true)).split(/\s+/)
+    var ret = (yield executil.execHelper(executil.ARGS('git tag --list'), true)).split(/\s+/)
         .reduce(function (curBest, value) {
             var modifiedCurBest, modifiedValue;
             if (prefix) {
@@ -54,14 +55,29 @@ exports.findMostRecentTag = function*(prefix) {
             if (semver.valid(modifiedValue)) {
                 //use finalBest to hold onto reference outside of reduce function
                 finalBest = !curBest ? value : semver.gt(modifiedCurBest, modifiedValue) ? finalBest : value;
+                if (curBest < finalBest) {
+                    lastBest = curBest;
+                }
                 return !curBest ? value : semver.gt(modifiedCurBest, modifiedValue) ? curBest : value;
             } else if (curBest && semver.valid(modifiedCurBest)) {
+                if (curBest < finalBest) {
+                    lastBest = curBest;
+                }
                 return curBest;
             } else if(finalBest) {
+                if (curBest < finalBest) {
+                    lastBest = curBest;
+                }
                 return finalBest;
             }
             return null;
         });
+
+        if (ret !== null) {
+            return [ finalBest, lastBest ];
+        } else {
+            return null;
+        }
 };
 
 exports.tagExists = function*(tagName) {

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/439db5d0/src/print-tags.js
----------------------------------------------------------------------
diff --git a/src/print-tags.js b/src/print-tags.js
index f47c9d7..9796e64 100644
--- a/src/print-tags.js
+++ b/src/print-tags.js
@@ -44,7 +44,7 @@ module.exports = function*(argv) {
         if (argv.tag){
             tag = argv.tag;
         } else {
-            tag = yield gitutil.findMostRecentTag(repo.versionPrefix);
+            tag = (yield gitutil.findMostRecentTag(repo.versionPrefix))[0];
         }
         if (!tag) {
             console.log('    ' + repo.repoName + ': NO TAGS');

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/439db5d0/src/update-release-notes.js
----------------------------------------------------------------------
diff --git a/src/update-release-notes.js b/src/update-release-notes.js
index bb2de5b..c86cf0b 100644
--- a/src/update-release-notes.js
+++ b/src/update-release-notes.js
@@ -35,7 +35,9 @@ module.exports = function*() {
         'Usage: $0 update-release-notes [--repo=ios]'
         )
         .options('from-tag', {desc: 'Update since a specific tag instead of the "most recent" tag'})
-        .options('to-tag', {desc: 'Update to a specific tag instead of "master"'});        
+        .options('to-tag', {desc: 'Update to a specific tag instead of "master"'})
+        .options('override-date', {desc: 'Update to a specific date instead of today.'})
+        .options('last-two-tags', {desc: 'Update with the latest and previous tagged commits'});        
     argv = opt.argv;
 
     if (argv.h) {
@@ -49,15 +51,21 @@ module.exports = function*() {
     cmd.push(['--pretty=format:* %s']);
     yield repoutil.forEachRepo(repos, function*(repo) {
         var fromTag, toTag;
-        if (argv['from-tag']){
-            fromTag = argv['from-tag'];
+        if (argv['last-two-tags']) {
+            var last_two = (yield gitutil.findMostRecentTag(repo.versionPrefix));
+            fromTag = last_two[1];
+            toTag = last_two[0];
         } else {
-            fromTag = yield gitutil.findMostRecentTag(repo.versionPrefix);
-        }
-        if (argv['to-tag']){
-            toTag = argv['to-tag'];
-        } else {
-            toTag = 'master';
+            if (argv['from-tag']){
+                fromTag = argv['from-tag'];
+            } else {
+                fromTag = (yield gitutil.findMostRecentTag(repo.versionPrefix))[0];
+            }
+            if (argv['to-tag']){
+                toTag = argv['to-tag'];
+            } else {
+                toTag = 'master';
+            }
         }
 
         cmd.push(fromTag + '..' + toTag);
@@ -78,7 +86,12 @@ module.exports = function*() {
             var relNotesFile = 'RELEASENOTES.md';
             var data = fs.readFileSync(relNotesFile, {encoding: 'utf8'});
             var pos = data.indexOf('### ');
-            var date = new Date().toDateString().split(' ');
+            var date;
+            if (argv['override-date']) {
+                date = new Date(argv['override-date']).toDateString().split(' ');
+            } else {
+                date = new Date().toDateString().split(' ');
+            }
             data = data.substr(0, pos) + "### " + newVersion + ' (' + date[1] + ' ' + date[2] + ', ' + date[3] + ')\n' + output + '\n\n' + data.substr(pos);
             fs.writeFileSync(relNotesFile, data, {encoding: 'utf8'});
             linkify.file(relNotesFile);


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