You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2017/01/19 22:10:26 UTC

cordova-coho git commit: split out some repo into accessible subcommands. update co to v4 for promise support.

Repository: cordova-coho
Updated Branches:
  refs/heads/plugins-releaser fd8bb2940 -> 3e6f5db74


split out some repo into accessible subcommands. update co to v4 for promise support.


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

Branch: refs/heads/plugins-releaser
Commit: 3e6f5db74a8546fad51edb467d93d05ddc0cf064
Parents: fd8bb29
Author: filmaj <ma...@gmail.com>
Authored: Thu Jan 19 14:10:21 2017 -0800
Committer: filmaj <ma...@gmail.com>
Committed: Thu Jan 19 14:10:21 2017 -0800

----------------------------------------------------------------------
 package.json          |  2 +-
 src/main.js           |  2 +-
 src/plugin-release.js | 15 ++++++++--
 src/repo-reset.js     | 73 ++++++++++++++++++++++++----------------------
 4 files changed, 53 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/3e6f5db7/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 4d68629..1817043 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
   },
   "dependencies": {
     "chalk": "~0.4",
-    "co": "~3.0",
+    "co": "~4.0",
     "glob": "^5.0.14",
     "gnode": "^0.1.0",
     "jira-linkify": "^2.2.3",

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/3e6f5db7/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index 32a0164..ae510b9 100644
--- a/src/main.js
+++ b/src/main.js
@@ -229,5 +229,5 @@ module.exports = function() {
         executil.verbose = true;
     }
     var entry = command.entryPoint;
-    co(entry)();
+    co(entry).then();
 };

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/3e6f5db7/src/plugin-release.js
----------------------------------------------------------------------
diff --git a/src/plugin-release.js b/src/plugin-release.js
index 02f1100..59fd370 100644
--- a/src/plugin-release.js
+++ b/src/plugin-release.js
@@ -17,6 +17,7 @@ specific language governing permissions and limitations
 under the License.
 */
 
+var co = require('co');
 var path = require('path');
 var fs = require('fs');
 var util = require('util');
@@ -29,6 +30,7 @@ var gitutil = require('./gitutil');
 var repoutil = require('./repoutil');
 var repoupdate = require('./repo-update');
 var repoclone = require('./repo-clone');
+var reporeset = require('./repo-reset');
 var versionutil = require('./versionutil');
 var jira_client = require('jira-client');
 var inquirer = require('inquirer');
@@ -47,7 +49,7 @@ var jira_issue_types; // store ref to all issue types supported by our JIRA inst
 var jira_task_issue; // store ref to the "task" issue type
 var plugin_base; // parent directory holding all cordova plugins
 
-module.exports.interactive = function *interactive_plugins_release() {
+function *interactive_plugins_release() {
     console.log('Hi! So you want to do a plugins release, do you?');
     console.log('Let\'s start with your JIRA credentials - this system will be interacting with Apache\'s JIRA instance (issues.apache.org) often.');
     inquirer.prompt([{
@@ -199,12 +201,20 @@ module.exports.interactive = function *interactive_plugins_release() {
                 plugin_base = path.resolve(path.normalize(answers.cwd));
                 // TODO: is `plugins_base` pass-able to cloneRepos here?
                 var plugin_repos = flagutil.computeReposFromFlag('plugins', {includeSvn:true});
-                yield require('./repo-clone').cloneRepos(plugin_repos, false, null);
+                // TODO: wrapping yields in co is fugly
+                return co.wrap(function *() {
+                    yield repoclone.cloneRepos(plugin_repos, false, null);
+                    yield reporeset.resetRepos(plugin_repos, ['master']);
+                    yield repoupdate.updateRepos(plugin_repos, ['master'], /*noFetch*/false);
+                    return true;
+                })();
             } else {
                 console.error('Well you should type in the correct location the first time. Or this section of coho code should be coded more robustly! Contributions welcome :P');
                 console.error('Please try again.');
                 process.exit(4);
             }
+        }).then(function() {
+            console.log('ok plugins are updated at this point, onwards!');
         });
     }, function(auth_err) {
         var keys = Object.keys(auth_err);
@@ -250,6 +260,7 @@ module.exports.interactive = function *interactive_plugins_release() {
      * TODO: Need ability to serialize process of plugins release - save state of the process at any point.
      */
 }
+module.exports.interactive = interactive_plugins_release;
 // TODO: what is shared between plugin-release and platform-release helpers? factor out into util/lib/whatever helper modules
 
 /*

http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/3e6f5db7/src/repo-reset.js
----------------------------------------------------------------------
diff --git a/src/repo-reset.js b/src/repo-reset.js
index 7be21f0..0d54f76 100644
--- a/src/repo-reset.js
+++ b/src/repo-reset.js
@@ -55,50 +55,53 @@ module.exports = function*(argv) {
     }
     var branches = Array.isArray(argv.b) ? argv.b : [argv.b];
     var repos = flagutil.computeReposFromFlag(argv.r);
+    yield module.exports.resetRepos(repos, branches);
+}
 
-    function *cleanRepo(repo) {
-        for (var i = 0; i < branches.length; ++i) {
-            var branchName = branches[i];
-            if (!(yield gitutil.localBranchExists(branchName))) {
-                continue;
-            }
-            // Commit local changes so that they can be restored if this was a mistake.
-            if (yield gitutil.pendingChangesExist()) {
-                print('Committing changes just in case resetting was a mistake.');
-                yield executil.execHelper(executil.ARGS('git add --all .'));
-                yield executil.execHelper(executil.ARGS('git commit -m', 'Automatically committed by coho repo-reset'));
-            }
-
-            if (yield gitutil.remoteBranchExists(repo, branchName)) {
-                yield gitutil.gitCheckout(branchName);
-                var changes = yield executil.execHelper(executil.ARGS('git log --oneline ' + repo.remoteName + '/' + branchName + '..' + branchName));
-                if (changes) {
-                    print(repo.repoName + ' on branch ' + branchName + ': Local commits exist. Resetting.');
-                    yield executil.execHelper(executil.ARGS('git reset --hard ' + repo.remoteName + '/' + branchName));
-                } else {
-                    print(repo.repoName + ' on branch ' + branchName + ': No local commits to reset.');
-                }
-            } else {
-                if ((yield gitutil.retrieveCurrentBranchName()) == branchName) {
-                    yield gitutil.gitCheckout('master');
-                }
-                print(repo.repoName + ' deleting local-only branch ' + branchName + '.');
-                yield executil.execHelper(executil.ARGS('git log --oneline -3 ' + branchName));
-                yield executil.execHelper(executil.ARGS('git branch -D ' + branchName));
-            }
-        }
-    }
+module.exports.resetRepos = function*(repos, branches) {
     yield repoutil.forEachRepo(repos, function*(repo) {
         // Determine remote name.
         yield repoupdate.updateRepos([repo], [], true);
         var branchName = yield gitutil.retrieveCurrentBranchName();
         if (branches.indexOf(branchName) == -1) {
             yield gitutil.stashAndPop(repo, function*() {
-                yield cleanRepo(repo);
+                yield cleanRepo(repo, branches);
             });
         } else {
-            yield cleanRepo(repo);
+            yield cleanRepo(repo, branches);
         }
     });
-}
+};
 
+function *cleanRepo(repo, branches) {
+    for (var i = 0; i < branches.length; ++i) {
+        var branchName = branches[i];
+        if (!(yield gitutil.localBranchExists(branchName))) {
+            continue;
+        }
+        // Commit local changes so that they can be restored if this was a mistake.
+        if (yield gitutil.pendingChangesExist()) {
+            print('Committing changes just in case resetting was a mistake.');
+            yield executil.execHelper(executil.ARGS('git add --all .'));
+            yield executil.execHelper(executil.ARGS('git commit -m', 'Automatically committed by coho repo-reset'));
+        }
+
+        if (yield gitutil.remoteBranchExists(repo, branchName)) {
+            yield gitutil.gitCheckout(branchName);
+            var changes = yield executil.execHelper(executil.ARGS('git log --oneline ' + repo.remoteName + '/' + branchName + '..' + branchName));
+            if (changes) {
+                print(repo.repoName + ' on branch ' + branchName + ': Local commits exist. Resetting.');
+                yield executil.execHelper(executil.ARGS('git reset --hard ' + repo.remoteName + '/' + branchName));
+            } else {
+                print(repo.repoName + ' on branch ' + branchName + ': No local commits to reset.');
+            }
+        } else {
+            if ((yield gitutil.retrieveCurrentBranchName()) == branchName) {
+                yield gitutil.gitCheckout('master');
+            }
+            print(repo.repoName + ' deleting local-only branch ' + branchName + '.');
+            yield executil.execHelper(executil.ARGS('git log --oneline -3 ' + branchName));
+            yield executil.execHelper(executil.ARGS('git branch -D ' + branchName));
+        }
+    }
+}


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