Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Unified Diff: depot_tools/presubmit_support.py

Issue 268023: This makes presubmit queries accept "yes" as well as "y" (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | depot_tools/tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: depot_tools/presubmit_support.py
===================================================================
--- depot_tools/presubmit_support.py (revision 28422)
+++ depot_tools/presubmit_support.py (working copy)
@@ -63,6 +63,10 @@
path = path.replace(os.sep, '/')
return os.path.normpath(path)
+def PromptYesNo(input_stream, output_stream, prompt):
+ output_stream.write(prompt)
+ response = input_stream.readline().strip().lower()
+ return response == 'y' or response == 'yes'
class OutputApi(object):
"""This class (more like a module) gets passed to presubmit scripts so that
@@ -102,9 +106,8 @@
self._long_text)
if self.ShouldPrompt() and may_prompt:
- output_stream.write('Are you sure you want to continue? (y/N): ')
- response = input_stream.readline()
- if response.strip().lower() != 'y':
+ if not PromptYesNo(input_stream, output_stream,
+ 'Are you sure you want to continue? (y/N): '):
return False
return not self.IsFatal()
@@ -953,10 +956,9 @@
print "Presubmit checks took %.1fs to calculate." % total_time
if not errors and warnings and may_prompt:
- output_stream.write(
- 'There were presubmit warnings. Sure you want to continue? (y/N): ')
- response = input_stream.readline()
- if response.strip().lower() != 'y':
+ if not PromptYesNo(input_stream, output_stream,
+ 'There were presubmit warnings. '
+ 'Are you sure you wish to continue? (y/N): '):
error_count += 1
global _ASKED_FOR_FEEDBACK
« no previous file with comments | « no previous file | depot_tools/tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698