fix prompting if there were errors in the hooks. Still need to write unit tests.
TBR=maruel@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@77922 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl/git_cl.py b/git_cl/git_cl.py
index e1e73b6..083db60 100644
--- a/git_cl/git_cl.py
+++ b/git_cl/git_cl.py
@@ -720,7 +720,7 @@
if not result:
return
-
+
stripcomment_re = re.compile(r'^#.*$', re.MULTILINE)
return stripcomment_re.sub('', result).strip()
@@ -775,15 +775,26 @@
output = StringIO.StringIO()
res = presubmit_support.DoPresubmitChecks(change, committing,
verbose=None, output_stream=output, input_stream=sys.stdin,
- default_presubmit=None, may_prompt=may_prompt, tbr=tbr,
+ default_presubmit=None, may_prompt=False, tbr=tbr,
host_url=cl.GetRietveldServer())
hook_results = HookResults(output.getvalue())
if hook_results.output:
print hook_results.output
# TODO(dpranke): We should propagate the error out instead of calling exit().
- if not res:
- sys.exit(1)
+ if not res and ('** Presubmit ERRORS **' in hook_results.output or
+ '** Presubmit WARNINGS **' in hook_results.output):
+ res = True
+
+ if res:
+ if may_prompt:
+ response = raw_input('Are you sure you want to continue? (y/N): ')
+ if not response.lower().startswith('y'):
+ sys.exit(1)
+ else:
+ sys.exit(1)
+
+
return hook_results