Skip to content

Commit

Permalink
PRESUBMIT: reject changes that add wstrings
Browse files Browse the repository at this point in the history
We are trying to get rid of wstrings, but new code keeps getting
checked in that adds more.  This will help prevent future mistakes.

Review URL: http://codereview.chromium.org/7886019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100974 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
evan@chromium.org committed Sep 13, 2011
1 parent c13b1e7 commit 8ea5d4b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ def _CheckNoIOStreamInHeaders(input_api, output_api):
return []


def _CheckNoNewWStrings(input_api, output_api):
"""Checks to make sure we don't introduce use of wstrings."""
errors = []
for f in input_api.AffectedFiles():
for line_num, line in f.ChangedContents():
if not f.LocalPath().endswith(('.cc', '.h')):
continue

if 'wstring' in line:
errors.append(output_api.PresubmitError(
'%s, line %d: new code should not use wstrings. If you are '
'calling an API that accepts a wstring, fix the API.'
% (f.LocalPath(), line_num)))

return errors


def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
results = []
Expand All @@ -121,6 +138,7 @@ def _CommonChecks(input_api, output_api):
results.extend(
_CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
results.extend(_CheckNoNewWStrings(input_api, output_api))
return results


Expand Down

0 comments on commit 8ea5d4b

Please sign in to comment.