cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject cordova-coho git commit: CB-12538: give release manager option of automatically merging master into release branch in the case the release branch already exists.
Date Fri, 03 Mar 2017 22:49:54 GMT
Repository: cordova-coho
Updated Branches:
  refs/heads/plugins-releaser 14f84bac5 -> 2f043a33f


CB-12538: give release manager option of automatically merging master into release branch
in the case the release branch already exists.


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

Branch: refs/heads/plugins-releaser
Commit: 2f043a33f9b80ae493ed3ec316823ef30d297310
Parents: 14f84ba
Author: filmaj <maj.fil@gmail.com>
Authored: Fri Mar 3 14:49:44 2017 -0800
Committer: filmaj <maj.fil@gmail.com>
Committed: Fri Mar 3 14:49:44 2017 -0800

----------------------------------------------------------------------
 src/executil.js             |  2 ++
 src/gitutil.js              | 16 ++++++++++++---
 src/plugin-release.js       | 44 ++++++++++++++++++++++++++++++++++------
 src/update-release-notes.js |  4 ++--
 4 files changed, 55 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/2f043a33/src/executil.js
----------------------------------------------------------------------
diff --git a/src/executil.js b/src/executil.js
index d389d25..3b294b5 100644
--- a/src/executil.js
+++ b/src/executil.js
@@ -38,6 +38,8 @@ exports.verbose = false;
 // silent == true or 1 ==> don't print command, don't print output
 // silent == 2 ==> don't print command, print output
 // silent == 3 ==> print command, don't print output
+// TODO: this function should be consolidated to promises, and shouldnt take win/fail callbacks.
+// some async confusion here
 function execHelper(cmdAndArgs, silent, allowError, win, fail) {
     // there are times where we want silent but not allowError.
     if (null == allowError) {

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/2f043a33/src/gitutil.js
----------------------------------------------------------------------
diff --git a/src/gitutil.js b/src/gitutil.js
index 15a23dd..d449ec0 100644
--- a/src/gitutil.js
+++ b/src/gitutil.js
@@ -105,8 +105,14 @@ exports.retrieveCurrentBranchName = function*(allowDetached) {
     return match[1];
 }
 
-exports.remoteBranchExists = function*(repo, name) {
-    return !!(yield executil.execHelper(executil.ARGS('git branch -r --list ' + repo.remoteName
+ '/' + name), true));
+exports.remoteBranchExists = function*(repo, branch) {
+    var branch_token = (repo.remoteName || 'origin') + '/' + branch;
+    var stdout = yield executil.execHelper(executil.ARGS('git branch -r --list ' + branch_token),
false, false);
+    if (stdout.indexOf(branch_token) > -1) {
+        return true;
+    } else {
+        return false;
+    }
 }
 
 exports.stashAndPop = function*(repo, func) {
@@ -180,10 +186,14 @@ exports.tagRepo = function*(version) {
 
 exports.pushToOrigin = function*(ref) {
     // TODO TEST: uncomment once ready to test
-    return yield executil.execHelper(executil.ARGS('git push origin', ref));
+    //return yield executil.execHelper(executil.ARGS('git push origin', ref));
 }
 
 exports.diff = function*(first, second) {
     var args = executil.ARGS('git diff', first + '..' + second);
     return yield executil.execHelper(args, true, false);
 }
+
+exports.merge = function*(ref, win, fail) {
+    return yield executil.execHelper(executil.ARGS('git merge', ref), false, false, win,
fail);
+}

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/2f043a33/src/plugin-release.js
----------------------------------------------------------------------
diff --git a/src/plugin-release.js b/src/plugin-release.js
index fa5b355..83c9174 100644
--- a/src/plugin-release.js
+++ b/src/plugin-release.js
@@ -62,6 +62,7 @@ var svn_repos; // cordova dist and dist/dev svn repos
 var plugin_data = {}; // massive object containing plugin release-relevant information
 var plugins_to_release = []; // array of plugin names that need releasing
 var plugins_ommitted = []; // array of plugin names that DO NOT need releasing
+var plugins_to_merge_manually = []; // array of plugin names that RM will need to merge master
into release branch manually.
 var svn_user; // username for apache svn
 var svn_password; // password for apache svn
 
@@ -359,7 +360,9 @@ function *interactive_plugins_release() {
             console.log('Removing the "-dev" suffix from versions...');
             return co.wrap(function *() {
                 yield repoutil.forEachRepo(plugin_repos, function*(repo) {
+                    yield gitutil.gitCheckout('master');
                     var current_version = yield versionutil.getRepoVersion(repo);
+                    console.log(repo.repoName, '\'s current version is', current_version);
                     var devless_version = versionutil.removeDev(current_version);
                     plugin_data[repo.repoName].current_release = devless_version;
                     yield versionutil.updateRepoVersion(repo, devless_version, {commitChanges:false});
@@ -456,19 +459,48 @@ function *interactive_plugins_release() {
         }).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.
             // Our mission in this clause, should we choose to accept it, is to merge master
back into the branch. But, this can be dangerous!
-            // TODO: Should we ask the user to handle the merge / cherry pick, then? Or should
we merge automatically?
-            // This section, right now, simply tells the user to handle the merge manually
in a seperate shell.
-            // IF THEY FAIL TO DO THIS, then we will seriously fuck shit up by pushing release
branches up (done in next promise section). :/
+            // Ask the RM if they want us to handle the merge automatically.
+            // If the RM says no, we will prompt them to handle it manually later.
             console.warn('Some release branches already exist!');
-            console.warn('You will need to manually cherry-pick or merge from master into
the release branch for these repos manually!');
             var prompts = [];
             repos_with_existing_release_branch.forEach(function(repo) {
                 var plugin_name = repo.repoName;
                 var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release)
                 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.'
+                    name: 'rb_automerge_proceed_' + plugin_name,
+                    message: plugin_name + ' already has an existing release branch "' +
rb + '". Do you want me to automatically merge master into this branch for you? If no, I will
prompt you to modify the release branch yourself at a later time in this session.'
+                });
+            });
+            return inquirer.prompt(prompts);
+        }).then(function(answers) {
+            return co.wrap(function *() {
+                var prompts = [];
+                yield repoutil.forEachRepo(plugin_repos, function*(repo) {
+                    var plugin_name = repo.repoName;
+                    if (answers['rb_automerge_proceed_' + plugin_name]) {
+                        // Auto-merge master into the release branch.
+                        var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release);
+                        console.log('Checking out "' + rb + '" branch of', plugin_name, 'merging
master in...');
+                        yield gitutil.gitCheckout(rb);
+                        yield gitutil.merge('master', function() { console.log('merge was
fine, continuing.'); }, function(e) {
+                            plugins_to_merge_manually.push(plugin_name);
+                        });
+                    } else {
+                        plugins_to_merge_manually.push(plugin_name);
+                    }
+                });
+                return inquirer.prompt(prompts);
+            })();
+        }).then(function() {
+            // prompt the RM about the plugins with manual merging work needed here.
+            var prompts = [];
+            plugins_to_merge_manually.forEach(function(plugin_name) {
+                var rb = versionutil.getReleaseBranchNameFromVersion(plugin_data[plugin_name].current_release)
+                prompts.push({
+                    type: 'confirm',
+                    name: 'rb_manualmerge_proceed_' + plugin_name,
+                    message: plugin_name + ' already has an existing release branch "' +
rb + '", and it needs a manual merge of master into it (either because you specified that,
or because there was a merge conflict during auto-merge. Now is your chance to manually merge
/ cherry-pick / resolve conflicts on the "' + rb + '" branch. Once you have done this (probably
in a separate shell or command prompt), hit Enter to continue.'
                 });
             });
             return inquirer.prompt(prompts);

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/2f043a33/src/update-release-notes.js
----------------------------------------------------------------------
diff --git a/src/update-release-notes.js b/src/update-release-notes.js
index b9f50f1..9e613ea 100644
--- a/src/update-release-notes.js
+++ b/src/update-release-notes.js
@@ -41,7 +41,7 @@ module.exports = function*() {
         .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('override-date', {desc: 'Update to a specific date instead of today.'})
-        .options('last-two-tags', {desc: 'Update with the latest and previous tagged commits'});
       
+        .options('last-two-tags', {desc: 'Update with the latest and previous tagged commits'});
     argv = opt.argv;
 
     if (argv.h) {
@@ -107,7 +107,7 @@ function *createNotes(repo, newVersion, changes, overrideDate) {
     // pump changes through JIRA linkifier first through a stream pipe
 	var transformer = linkify.stream("CB");
 	var read = new stream.Readable();
-	read._read = function(){};// noop 
+	read._read = function(){};// noop
 	read.push(changes);
 	read.push(null);
 	var write = new stream.Writable();


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


Mime
View raw message