Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5BC8B105F3 for ; Fri, 10 Apr 2015 02:15:29 +0000 (UTC) Received: (qmail 27264 invoked by uid 500); 10 Apr 2015 02:15:29 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 27236 invoked by uid 500); 10 Apr 2015 02:15:29 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 27227 invoked by uid 99); 10 Apr 2015 02:15:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Apr 2015 02:15:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0CAF9E00AD; Fri, 10 Apr 2015 02:15:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Message-Id: <7f254bd6b7fd4e70a2a02fe48f4bf6b2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cordova-coho git commit: Make repo-reset safer by committing before resetting Date: Fri, 10 Apr 2015 02:15:29 +0000 (UTC) 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 Authored: Thu Apr 9 22:15:14 2015 -0400 Committer: Andrew Grieve 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