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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py

Issue 2598743002: When importing w3c repos, convert CRLF line endings. (Closed)
Patch Set: Created 4 years 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 | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
index 12b0235808a21a6dfc033474e8b8d16febfdfa49..8b18b1c78263b421fe3006e721cb614925717b7a 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
@@ -419,11 +419,28 @@ class TestImporter(object):
else:
if not self.import_in_place and not self.options.dry_run:
self.filesystem.copyfile(source_path, dest_path)
- if self.filesystem.read_binary_file(source_path)[:2] == '#!':
- self.filesystem.make_executable(dest_path)
+ self._transform_for_presubmit(dest_path)
return dest_path.replace(self._webkit_root, '')
+ def _transform_for_presubmit(self, path):
+ """Changes a file in order to pass the Chromium top-level presubmit.
+
+ This should only transform text files; if the Chromium presubmit is
+ changed to ignore imported files, then this would be unnecessary.
+ """
+ # There may be some text files that are encoded with utf-16 or other
+ # encodings, but these are rare.
+ try:
+ text = self.filesystem.read_text_file(path)
+ except UnicodeDecodeError:
+ return
+ if text[:2] == '#!':
+ self.filesystem.make_executable(path)
+ if '\r\n' in text:
+ _log.warning('File %s has CRLF line endings.', path)
+ self.filesystem.write_text_file(path, text.replace('\r\n', '\n'))
+
@staticmethod
def should_try_to_convert(file_to_copy, source_path, dest_dir):
"""Checks whether we should try to modify the file when importing."""
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698