Commit efb9450e authored by gspencer@google.com's avatar gspencer@google.com

This makes presubmit queries accept "yes" as well as "y"

as an answer.
Review URL: http://codereview.chromium.org/268023

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@28557 0039d316-1c4b-4281-b951-d872f2087c98
parent 7658eb3c
......@@ -63,6 +63,10 @@ def normpath(path):
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 @@ class OutputApi(object):
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 @@ def DoPresubmitChecks(change,
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
......
......@@ -78,15 +78,16 @@ class PresubmitUnittest(PresubmitTestsBase):
self.mox.ReplayAll()
members = [
'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks',
'GetTrySlavesExecuter', 'GitChange', 'GitAffectedFile', 'InputApi',
'ListRelevantPresubmitFiles', 'Main', 'NotImplementedException',
'OutputApi', 'ParseFiles', 'PresubmitExecuter', 'ScanSubDirs',
'SvnAffectedFile', 'SvnChange',
'cPickle', 'cStringIO', 'exceptions',
'fnmatch', 'gcl', 'gclient_scm', 'glob', 'logging', 'marshal', 'normpath',
'optparse', 'os', 'pickle',
'presubmit_canned_checks', 'random', 're', 'subprocess', 'sys', 'time',
'tempfile', 'traceback', 'types', 'unittest', 'urllib2', 'warnings',
'GetTrySlavesExecuter', 'GitAffectedFile', 'GitChange',
'InputApi', 'ListRelevantPresubmitFiles', 'Main',
'NotImplementedException', 'OutputApi', 'ParseFiles',
'PresubmitExecuter', 'PromptYesNo', 'ScanSubDirs',
'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO',
'exceptions', 'fnmatch', 'gcl', 'gclient_scm', 'glob',
'logging', 'marshal', 'normpath', 'optparse', 'os', 'pickle',
'presubmit_canned_checks', 'random', 're', 'subprocess', 'sys',
'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2',
'warnings',
]
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit, members)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment