cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [09/35] cordova-coho git commit: added createNewBranch gitutil. added getReleaseBranchFromVersion versionutil. platform release uses new getReleaseBranchFromVersion method. determine whether plugin repos have release branch in them or not, and prompt use
Date Wed, 26 Apr 2017 01:04:04 GMT
added createNewBranch gitutil. added getReleaseBranchFromVersion versionutil. platform release
uses new getReleaseBranchFromVersion method. determine whether plugin repos have release branch
in them or not, and prompt user to manually merge/cherry-pick in the case that release branch
already exists, otherwise, create the release branch.


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

Branch: refs/heads/master
Commit: ba4dd93390fde9b8343285b266ffb68a2f5d94e7
Parents: 9a7a5cc
Author: filmaj <maj.fil@gmail.com>
Authored: Wed Feb 1 16:20:50 2017 -0800
Committer: filmaj <maj.fil@gmail.com>
Committed: Tue Apr 25 17:26:17 2017 -0700

----------------------------------------------------------------------
 src/gitutil.js          |  4 ++++
 src/platform-release.js | 11 ++-------
 src/plugin-release.js   | 55 ++++++++++++++++++++++++++++++++------------
 src/versionutil.js      |  7 ++++++
 4 files changed, 53 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/ba4dd933/src/gitutil.js
----------------------------------------------------------------------
diff --git a/src/gitutil.js b/src/gitutil.js
index 058ff96..dcc7fcd 100644
--- a/src/gitutil.js
+++ b/src/gitutil.js
@@ -136,6 +136,10 @@ exports.gitCheckout = function*(branchName) {
     }
 }
 
+exports.createNewBranch = function*(branchName) {
+    return yield executil.execHelper(executil.ARGS('git branch ', branchName));
+}
+
 exports.localBranchExists = function*(name) {
     return !!(yield executil.execHelper(executil.ARGS('git branch --list ' + name), true));
 }

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/ba4dd933/src/platform-release.js
----------------------------------------------------------------------
diff --git a/src/platform-release.js b/src/platform-release.js
index 3ea90b1..9e9df33 100644
--- a/src/platform-release.js
+++ b/src/platform-release.js
@@ -43,13 +43,6 @@ function createPlatformDevVersion(version) {
     return parts.join('.') + '-dev';
 }
 
-function getVersionBranchName(version) {
-    if (/-dev$/.test(version)) {
-        return 'master';
-    }
-    return version.replace(/\d+(-?rc\d)?$/, 'x');
-}
-
 function cpAndLog(src, dest) {
     print('Coping File:', src, '->', dest);
     // Throws upon failure.
@@ -215,7 +208,7 @@ exports.prepareReleaseBranchCommand = function*() {
     yield repoutil.forEachRepo(repos, function*(repo) {
         var platform = repo.id;
         var version = yield handleVersion(repo, argv.version,true);
-        var branchName = getVersionBranchName(version);
+        var branchName = versionutil.getReleaseBranchNameFromVersion(version);
 
         yield gitutil.stashAndPop(repo, function*() {
             // git fetch + update master
@@ -296,7 +289,7 @@ exports.tagReleaseBranchCommand = function*(argv) {
     var repos = flagutil.computeReposFromFlag(argv.r);
     var version = flagutil.validateVersionString(argv.version);
     var pretend = argv.pretend;
-    var branchName = getVersionBranchName(version);
+    var branchName = versionutil.getReleaseBranchNameFromVersion(version);
 
     // First - perform precondition checks.
     yield repoupdate.updateRepos(repos, [], true);

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/ba4dd933/src/plugin-release.js
----------------------------------------------------------------------
diff --git a/src/plugin-release.js b/src/plugin-release.js
index 2a0a7e4..6b64b2a 100644
--- a/src/plugin-release.js
+++ b/src/plugin-release.js
@@ -359,31 +359,63 @@ function *interactive_plugins_release() {
                 console.log('Writing out new release notes and plugin versions (if applicable)...');
                 yield repoutil.forEachRepo(plugin_repos, function*(repo) {
                     var plugin_name = repo.repoName;
-                    if (plugin_data[repo.repoName].current_release != release_notes[plugin_name
+ '-version']) {
+                    if (plugin_data[plugin_name].current_release != release_notes[plugin_name
+ '-version']) {
                         // Overwrite plugin version if, after release notes review, RM decided
on a different version.
-                        plugin_data[repo.repoName].current_release = release_notes[plugin_name
+ '-version'];
-                        yield versionutil.updateRepoVersion(repo, plugin_data[repo.repoName].current_release,
{commitChanges:false});
+                        plugin_data[plugin_name].current_release = release_notes[plugin_name
+ '-version'];
+                        yield versionutil.updateRepoVersion(repo, plugin_data[plugin_name].current_release,
{commitChanges:false});
                     }
                     fs.writeFileSync(tweak_release_notes.FILE, release_notes[plugin_name],
{encoding: 'utf8'});
                     linkify.file(tweak_release_notes.FILE);
                     /* - commit changes to versions and release notes together with description
'$JIRA Updated version and release notes for release $v'
                      * - tag each plugin repo with $v*/
                     if (yield gitutil.pendingChangesExist()) {
-                        yield gitutil.commitChanges(plugins_release_issue.key + ' Updated
version and RELEASENOTES.md for release ' + plugin_data[repo.repoName].current_release);
-                        yield gitutil.tagRepo(plugin_data[repo.repoName].current_release);
+                        yield gitutil.commitChanges(plugins_release_issue.key + ' Updated
version and RELEASENOTES.md for release ' + plugin_data[plugin_name].current_release);
+                        yield gitutil.tagRepo(plugin_data[plugin_name].current_release);
                     } else {
-                        console.warn('No pending changes detected for ' + repo.repoName +
'; that\'s probably not good eh?');
+                        console.warn('No pending changes detected for ' + plugin_name + ';
that\'s probably not good eh?');
                     }
                 });
             })();
+        }).then(function() {
+            /* 10. Create release branch.Check if release branch, which would be named in
the form "major.minor.x" (i.e. 2.3.x) already exists */
+            return co.wrap(function *() {
+                var repos_with_existing_release_branch = [];
+                yield repoutil.forEachRepo(plugin_repos, function*(repo) {
+                    var plugin_name = repo.repoName;
+                    var plugin_version = plugin_data[plugin_name].current_release;
+                    var release_branch_name = versionutil.getReleaseBranchNameFromVersion(plugin_version);
+                    if (yield gitutil.remoteBranchExists(repo, release_branch_name)) {
+                        repos_with_existing_release_branch.push(repo);
+                    } else {
+                        yield gitutil.createNewBranch(release_branch_name);
+                        console.log('Created branch', release_branch_name, 'in repo', plugin_name);
+                    }
+                });
+            })();
+        }).then(function(repos_with_existing_release_branch) {
+            // Here we are passed an array of repos that already had release branches created
prior to starting the release process here.
+            // Our mission in this clause, should we choose to accept it, is to merge master
back into the branch. But, this can be dangerous! 
+            // Should we ask the user to handle the merge / cherry pick, then? Or should
we merge automatically?
+            console.warn('Some release branches already exist!');
+            console.warn('You will need to handle these repos manually!');
+            var prompts = [];
+            repos_with_existing_branch_name.forEach(function(repo) {
+                var plugin_name = repo.repoName;
+                var rb = versionutil.getReleaseBranchFromVersion(plugin_data[plugin_name].current_version)
+                prompts.push({
+                    type: 'confirm',
+                    name: 'rb_proceed_' + plugin_name,
+                    message: plugin_name + ' already has an existing release branch ' + rb
+ '. You will need to manually merge or cherry-pick the master branch into the ' + rb + '
branch. Once you have done this (probably in a separate shell or command prompt), hit Enter
to continue.'
+                });
+            });
+            return inquirer.prompt(prompts);
         });
     }, function(auth_err) {
         var keys = Object.keys(auth_err);
         console.error('ERROR! There was a problem connecting to JIRA, received a', auth_err.statusCode,
'status code.');
         process.exit(1);
     });
-    /* 10. Create release branch. if this is a patch release, it may already exist! in that
case, merge master back into this existing release branch.
-     * 11. Increment plugin versions back on the master branch to include -dev.. i think?
+    /* 11. Increment plugin versions back on the master branch to include -dev
      * 12. Push tags, release branch, and master branch changes.
      * 13. Publish to apache svn:
      *   - repo-clone the dist and dist/dev svn repos
@@ -424,13 +456,6 @@ function createPlatformDevVersion(version) {
     return parts.join('.') + '-dev';
 }
 
-function getVersionBranchName(version) {
-    if (/-dev$/.test(version)) {
-        return 'master';
-    }
-    return version.replace(/\d+(-?rc\d)?$/, 'x');
-}
-
 function cpAndLog(src, dest) {
     print('Coping File:', src, '->', dest);
     // Throws upon failure.

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/ba4dd933/src/versionutil.js
----------------------------------------------------------------------
diff --git a/src/versionutil.js b/src/versionutil.js
index c6613bf..7fd7b52 100644
--- a/src/versionutil.js
+++ b/src/versionutil.js
@@ -70,6 +70,13 @@ function updatePlatformsConfig(newValues) {
 }
 exports.updatePlatformsConfig = updatePlatformsConfig;
 
+exports.getReleaseBranchNameFromVersion = function(version) {
+    if (/-dev$/.test(version)) {
+        return 'master';
+    }
+    return version.replace(/\d+(-?rc\d)?$/, 'x');
+}
+
 /**
  * Updates VERSION file, version executable script, package.json and
  * plugin.xml(s) using specified version. Also commits change made to the repo


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


Mime
View raw message