| Index: tools/presubmit.py
|
| diff --git a/tools/presubmit.py b/tools/presubmit.py
|
| index c191fc7497045d86794078badcb5b685b278ea77..dd842213d2440306be053a48f336c1264ad18c30 100755
|
| --- a/tools/presubmit.py
|
| +++ b/tools/presubmit.py
|
| @@ -1,6 +1,6 @@
|
| #!/usr/bin/env python
|
| #
|
| -# Copyright 2008 the V8 project authors. All rights reserved.
|
| +# Copyright 2011 the V8 project authors. All rights reserved.
|
| # Redistribution and use in source and binary forms, with or without
|
| # modification, are permitted provided that the following conditions are
|
| # met:
|
| @@ -231,11 +231,13 @@ COPYRIGHT_HEADER_PATTERN = re.compile(
|
|
|
| class SourceProcessor(SourceFileProcessor):
|
| """
|
| - Check that all files include a copyright notice.
|
| + Check that all files include a copyright notice and no trailing whitespaces.
|
| """
|
|
|
| RELEVANT_EXTENSIONS = ['.js', '.cc', '.h', '.py', '.c', 'SConscript',
|
| - 'SConstruct', '.status']
|
| + 'SConstruct', '.status', '.gyp', '.gypi']
|
| + IGNORE_TRAILING_WHITESPACE_EXTENSIONS = ['.c', '.cc', '.h']
|
| +
|
| def IsRelevant(self, name):
|
| for ext in SourceProcessor.RELEVANT_EXTENSIONS:
|
| if name.endswith(ext):
|
| @@ -273,6 +275,23 @@ class SourceProcessor(SourceFileProcessor):
|
| if not COPYRIGHT_HEADER_PATTERN.search(contents):
|
| print "%s is missing a correct copyright header." % name
|
| result = False
|
| + ext = base.split('.').pop()
|
| + if not ext in SourceProcessor.IGNORE_TRAILING_WHITESPACE_EXTENSIONS and \
|
| + ' \n' in contents or contents.endswith(' '):
|
| + line = 0
|
| + lines = []
|
| + parts = contents.split(' \n')
|
| + if not contents.endswith(' '):
|
| + parts.pop()
|
| + for part in parts:
|
| + line += part.count('\n') + 1
|
| + lines.append(str(line))
|
| + linenumbers = ', '.join(lines)
|
| + if len(lines) > 1:
|
| + print "%s has trailing whitespaces in lines: %s" % (name, linenumbers)
|
| + else:
|
| + print "%s has trailing whitespaces in line %s" % (name, linenumbers)
|
| + result = False
|
| return result
|
|
|
| def ProcessFiles(self, files, path):
|
|
|