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

Unified Diff: presubmit_canned_checks.py

Issue 118370: Add InputApi.ReadFile() and presubmit_canned_checks.CheckChangeHasNoCR(). (Closed)
Patch Set: Use mode 'rb' Created 11 years, 6 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 | presubmit_support.py » ('j') | presubmit_support.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 7897effd7896702a06d975ae25997754cb8d6048..b8cbd94d33102ae27c9db27b1ed87dce3bb00f35 100755
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -68,6 +68,18 @@ def CheckDoNotSubmit(input_api, output_api):
)
+def CheckChangeHasNoCR(input_api, output_api):
+ """Checks that there are no \r, \r\n (CR or CRLF) characters in any of the
+ text files to be submitted.
+ """
+ outputs = []
+ for f in input_api.AffectedTextFiles():
+ if '\r' in input_api.ReadFile(f, 'rb'):
+ outputs.append(output_api.PresubmitPromptWarning(
+ "Found a CR character in %s" % f.LocalPath()))
+ return outputs
+
+
def CheckChangeHasNoTabs(input_api, output_api):
"""Checks that there are no tab characters in any of the text files to be
submitted.
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | presubmit_support.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698