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/04/24 18:11:57 UTC
[2/2] git commit: repo-push module
repo-push module
Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/5fe52de8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/5fe52de8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/5fe52de8
Branch: refs/heads/master
Commit: 5fe52de8fe94ef37d4e7e8c975152cbb722803c3
Parents: 0539868
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 24 12:11:42 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 24 12:11:42 2014 -0400
----------------------------------------------------------------------
src/main.js | 50 +--------------------------------
src/repo-push.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/5fe52de8/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index eae9fef..c0c5221 100644
--- a/src/main.js
+++ b/src/main.js
@@ -71,54 +71,6 @@ function retrieveCurrentTagName() {
return executil.execHelper(executil.ARGS('git describe --tags HEAD'), true, true);
}
-function *repoPushCommand(argv) {
- var opt = flagutil.registerRepoFlag(optimist)
- var opt = optimist
- .options('b', {
- alias: 'branch',
- desc: 'The name of the branch to push. Can be specified multiple times to specify multiple branches.',
- default: ['master', 'dev']
- });
- opt = flagutil.registerHelpFlag(opt);
- var argv = opt
- .usage('Pushes changes to the remote repository.\n' +
- '\n' +
- 'Usage: $0 repo-push -r auto -b master -b 2.9.x')
- .argv;
-
- if (argv.h) {
- optimist.showHelp();
- process.exit(1);
- }
- var branches = Array.isArray(argv.b) ? argv.b : [argv.b];
- var repos = flagutil.computeReposFromFlag(argv.r);
-
- yield repoutil.forEachRepo(repos, function*(repo) {
- // Update first.
- yield repoupdate.updateRepos([repo], branches, false);
- for (var i = 0; i < branches.length; ++i) {
- var branchName = branches[i];
- if (!(yield gitutil.localBranchExists(branchName))) {
- continue;
- }
- var isNewBranch = !(yield gitutil.remoteBranchExists(repo, branchName));
-
- yield gitutil.gitCheckout(branchName);
-
- if (isNewBranch) {
- yield executil.execHelper(executil.ARGS('git push --set-upstream ' + repo.remoteName + ' ' + branchName));
- } else {
- var changes = yield executil.execHelper(executil.ARGS('git log --oneline ' + repo.remoteName + '/' + branchName + '..' + branchName), true);
- if (changes) {
- yield executil.execHelper(executil.ARGS('git push ' + repo.remoteName + ' ' + branchName));
- } else {
- print(repo.repoName + ' on branch ' + branchName + ': No local commits exist.');
- }
- }
- }
- });
-}
-
function configureReleaseCommandFlags(opt) {
var opt = flagutil.registerRepoFlag(opt)
opt = opt
@@ -342,7 +294,7 @@ function main() {
}, {
name: 'repo-push',
desc: 'Push changes that exist locally but have not yet been pushed.',
- entryPoint: repoPushCommand
+ entryPoint: require('./repo-push')
}, {
name: 'list-repos',
desc: 'Shows a list of valid values for the --repo flag.',
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/5fe52de8/src/repo-push.js
----------------------------------------------------------------------
diff --git a/src/repo-push.js b/src/repo-push.js
new file mode 100644
index 0000000..2918be6
--- /dev/null
+++ b/src/repo-push.js
@@ -0,0 +1,76 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var optimist = require('optimist');
+var apputil = require('./apputil');
+var executil = require('./executil');
+var flagutil = require('./flagutil');
+var gitutil = require('./gitutil');
+var repoutil = require('./repoutil');
+var repoupdate = require('./repo-update');
+var print = apputil.print;
+
+module.exports = function*(argv) {
+ var opt = flagutil.registerRepoFlag(optimist)
+ var opt = optimist
+ .options('b', {
+ alias: 'branch',
+ desc: 'The name of the branch to push. Can be specified multiple times to specify multiple branches.',
+ default: ['master', 'dev']
+ });
+ opt = flagutil.registerHelpFlag(opt);
+ var argv = opt
+ .usage('Pushes changes to the remote repository.\n' +
+ '\n' +
+ 'Usage: $0 repo-push -r auto -b master -b 2.9.x')
+ .argv;
+
+ if (argv.h) {
+ optimist.showHelp();
+ process.exit(1);
+ }
+ var branches = Array.isArray(argv.b) ? argv.b : [argv.b];
+ var repos = flagutil.computeReposFromFlag(argv.r);
+
+ yield repoutil.forEachRepo(repos, function*(repo) {
+ // Update first.
+ yield repoupdate.updateRepos([repo], branches, false);
+ for (var i = 0; i < branches.length; ++i) {
+ var branchName = branches[i];
+ if (!(yield gitutil.localBranchExists(branchName))) {
+ continue;
+ }
+ var isNewBranch = !(yield gitutil.remoteBranchExists(repo, branchName));
+
+ yield gitutil.gitCheckout(branchName);
+
+ if (isNewBranch) {
+ yield executil.execHelper(executil.ARGS('git push --set-upstream ' + repo.remoteName + ' ' + branchName));
+ } else {
+ var changes = yield executil.execHelper(executil.ARGS('git log --oneline ' + repo.remoteName + '/' + branchName + '..' + branchName), true);
+ if (changes) {
+ yield executil.execHelper(executil.ARGS('git push ' + repo.remoteName + ' ' + branchName));
+ } else {
+ print(repo.repoName + ' on branch ' + branchName + ': No local commits exist.');
+ }
+ }
+ }
+ });
+}
+