cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject cordova-coho git commit: Make repo-reset safer by committing before resetting
Date Fri, 10 Apr 2015 02:15:29 GMT
Repository: cordova-coho
Updated Branches:
  refs/heads/master 08aa4c0b1 -> b6a83e0ef


Make repo-reset safer by committing before resetting


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

Branch: refs/heads/master
Commit: b6a83e0ef451b39f75a49dee874c6a25684ad700
Parents: 08aa4c0
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Apr 9 22:15:14 2015 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Apr 9 22:15:14 2015 -0400

----------------------------------------------------------------------
 src/repo-reset.js | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/b6a83e0e/src/repo-reset.js
----------------------------------------------------------------------
diff --git a/src/repo-reset.js b/src/repo-reset.js
index 4cbcf84..7be21f0 100644
--- a/src/repo-reset.js
+++ b/src/repo-reset.js
@@ -38,8 +38,8 @@ module.exports = function*(argv) {
     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' +
+               '    git commit                             (commit any pending changes)\n'
+
+               '    git reset --hard origin/$BRANCH_NAME   (revert un-pushed commits)\n'
+
                '    if ($BRANCH_NAME exists only locally) then\n' +
                '        git branch -D $BRANCH_NAME\n' +
                '\n' +
@@ -50,6 +50,9 @@ module.exports = function*(argv) {
         optimist.showHelp();
         process.exit(1);
     }
+    if (argv.r == 'auto') {
+        apputil.fatal('"-r auto" is not allowed for repo-reset. Please enumerate repos explicitly');
+    }
     var branches = Array.isArray(argv.b) ? argv.b : [argv.b];
     var repos = flagutil.computeReposFromFlag(argv.r);
 
@@ -59,6 +62,13 @@ module.exports = function*(argv) {
             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));
@@ -87,7 +97,6 @@ module.exports = function*(argv) {
                 yield cleanRepo(repo);
             });
         } else {
-            yield executil.execHelper(executil.ARGS('git clean -f -d'));
             yield cleanRepo(repo);
         }
     });


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


Mime
View raw message