cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/2] git commit: repo-reset module
Date Thu, 24 Apr 2014 16:11:56 GMT
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 <agrieve@chromium.org>
Authored: Thu Apr 24 12:09:54 2014 -0400
Committer: Andrew Grieve <agrieve@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);
+        }
+    });
+}
+


Mime
View raw message