From 495ad157213ca8ebdcbb07a0b1b7d460dfa6e971 Mon Sep 17 00:00:00 2001 From: "sbc@chromium.org" Date: Tue, 4 Sep 2012 23:07:42 +0000 Subject: [PATCH] Add --force option for presubmit command which allows one to run the presubmit script without submitting locally (alternative would be to make this a warning I guess). Also, pass option.verbose through to DoGetTrySlaves() so it will log which PRESUBMIT files are taking part in the decision. BUG= Review URL: https://chromiumcodereview.appspot.com/10915072 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@154838 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 7 +++++-- trychange.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/git_cl.py b/git_cl.py index c8c3c8fad..48fb848c8 100755 --- a/git_cl.py +++ b/git_cl.py @@ -926,13 +926,16 @@ def CMDpresubmit(parser, args): """run presubmit tests on the current changelist""" parser.add_option('--upload', action='store_true', help='Run upload hook instead of the push/dcommit hook') + parser.add_option('--force', action='store_true', + help='Run checks even if tree is dirty') (options, args) = parser.parse_args(args) # Make sure index is up-to-date before running diff-index. RunGit(['update-index', '--refresh', '-q'], error_ok=True) - if RunGit(['diff-index', 'HEAD']): + if not options.force and RunGit(['diff-index', 'HEAD']): # TODO(maruel): Is this really necessary? - print 'Cannot presubmit with a dirty tree. You must commit locally first.' + print ('Cannot presubmit with a dirty tree.\n' + 'You must commit locally first (or use --force).') return 1 cl = Changelist() diff --git a/trychange.py b/trychange.py index 042b9391c..39b827b10 100755 --- a/trychange.py +++ b/trychange.py @@ -819,7 +819,7 @@ def TryChange(argv, checkouts[0].checkout_root, root_presubmit, options.project, - False, + options.verbose, sys.stdout) except ImportError: pass