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:56 UTC
[1/2] git commit: repo-reset module
Repository: cordova-coho
Updated Branches:
refs/heads/master 29a3289fe -> 5fe52de8f
repo-reset 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/05398688
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/05398688
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/05398688
Branch: refs/heads/master
Commit: 053986888ef9abbc7b4aa99f1ba79474ed698739
Parents: 29a3289
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Apr 24 12:09:54 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Apr 24 12:09:54 2014 -0400
----------------------------------------------------------------------
src/main.js | 69 +-----------------------------------
src/repo-reset.js | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 96 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/05398688/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index a2a7d2d..eae9fef 100644
--- a/src/main.js
+++ b/src/main.js
@@ -71,73 +71,6 @@ function retrieveCurrentTagName() {
return executil.execHelper(executil.ARGS('git describe --tags HEAD'), true, true);
}
-function *repoResetCommand(argv) {
- var opt = flagutil.registerRepoFlag(optimist)
- var opt = optimist
- .options('b', {
- alias: 'branch',
- desc: 'The name of the branch to reset. Can be specified multiple times to specify multiple branches.',
- default: 'master'
- });
- opt = flagutil.registerHelpFlag(opt);
- var argv = opt
- .usage('Resets repository branches to match their upstream state.\n' +
- 'Performs the following commands on each:\n' +
- ' git reset --hard origin/$BRANCH_NAME\n' +
- ' git clean -f -d\n' +
- ' if ($BRANCH_NAME exists only locally) then\n' +
- ' git branch -D $BRANCH_NAME\n' +
- '\n' +
- 'Usage: $0 repo-reset -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);
-
- function *cleanRepo(repo) {
- for (var i = 0; i < branches.length; ++i) {
- var branchName = branches[i];
- if (!(yield gitutil.localBranchExists(branchName))) {
- continue;
- }
- 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));
- }
- }
- }
- 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);
- });
- } else {
- yield executil.execHelper(executil.ARGS('git clean -f -d'));
- yield cleanRepo(repo);
- }
- });
-}
-
function *repoPushCommand(argv) {
var opt = flagutil.registerRepoFlag(optimist)
var opt = optimist
@@ -401,7 +334,7 @@ function main() {
}, {
name: 'repo-reset',
desc: 'Performs git reset --hard origin/$BRANCH and git clean -f -d on all specified repositories.',
- entryPoint: repoResetCommand
+ entryPoint: require('./repo-reset')
}, {
name: 'repo-status',
desc: 'Lists changes that exist locally but have not yet been pushed.',
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/05398688/src/repo-reset.js
----------------------------------------------------------------------
diff --git a/src/repo-reset.js b/src/repo-reset.js
new file mode 100644
index 0000000..4cbcf84
--- /dev/null
+++ b/src/repo-reset.js
@@ -0,0 +1,95 @@
+/*
+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 reset. Can be specified multiple times to specify multiple branches.',
+ default: 'master'
+ });
+ opt = flagutil.registerHelpFlag(opt);
+ var argv = opt
+ .usage('Resets repository branches to match their upstream state.\n' +
+ 'Performs the following commands on each:\n' +
+ ' git reset --hard origin/$BRANCH_NAME\n' +
+ ' git clean -f -d\n' +
+ ' if ($BRANCH_NAME exists only locally) then\n' +
+ ' git branch -D $BRANCH_NAME\n' +
+ '\n' +
+ 'Usage: $0 repo-reset -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);
+
+ function *cleanRepo(repo) {
+ for (var i = 0; i < branches.length; ++i) {
+ var branchName = branches[i];
+ if (!(yield gitutil.localBranchExists(branchName))) {
+ continue;
+ }
+ 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));
+ }
+ }
+ }
+ 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);
+ });
+ } else {
+ yield executil.execHelper(executil.ARGS('git clean -f -d'));
+ yield cleanRepo(repo);
+ }
+ });
+}
+
[2/2] git commit: repo-push module
Posted by ag...@apache.org.
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.');
+ }
+ }
+ }
+ });
+}
+