OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 | 276 |
277 COPYRIGHT_HEADER_PATTERN = re.compile( | 277 COPYRIGHT_HEADER_PATTERN = re.compile( |
278 r'Copyright [\d-]*20[0-1][0-9] the V8 project authors. All rights reserved.'
) | 278 r'Copyright [\d-]*20[0-1][0-9] the V8 project authors. All rights reserved.'
) |
279 | 279 |
280 class SourceProcessor(SourceFileProcessor): | 280 class SourceProcessor(SourceFileProcessor): |
281 """ | 281 """ |
282 Check that all files include a copyright notice and no trailing whitespaces. | 282 Check that all files include a copyright notice and no trailing whitespaces. |
283 """ | 283 """ |
284 | 284 |
285 RELEVANT_EXTENSIONS = ['.js', '.cc', '.h', '.py', '.c', | 285 RELEVANT_EXTENSIONS = ['.js', '.cc', '.h', '.py', '.c', 'SConscript', |
286 '.status', '.gyp', '.gypi'] | 286 'SConstruct', '.status', '.gyp', '.gypi'] |
287 | 287 |
288 # Overwriting the one in the parent class. | 288 # Overwriting the one in the parent class. |
289 def FindFilesIn(self, path): | 289 def FindFilesIn(self, path): |
290 if os.path.exists(path+'/.git'): | 290 if os.path.exists(path+'/.git'): |
291 output = subprocess.Popen('git ls-files --full-name', | 291 output = subprocess.Popen('git ls-files --full-name', |
292 stdout=PIPE, cwd=path, shell=True) | 292 stdout=PIPE, cwd=path, shell=True) |
293 result = [] | 293 result = [] |
294 for file in output.stdout.read().split(): | 294 for file in output.stdout.read().split(): |
295 for dir_part in os.path.dirname(file).replace(os.sep, '/').split('/'): | 295 for dir_part in os.path.dirname(file).split(os.sep): |
296 if self.IgnoreDir(dir_part): | 296 if self.IgnoreDir(dir_part): |
297 break | 297 break |
298 else: | 298 else: |
299 if self.IsRelevant(file) and not self.IgnoreFile(file): | 299 if self.IsRelevant(file) and not self.IgnoreFile(file): |
300 result.append(join(path, file)) | 300 result.append(join(path, file)) |
301 if output.wait() == 0: | 301 if output.wait() == 0: |
302 return result | 302 return result |
303 return super(SourceProcessor, self).FindFilesIn(path) | 303 return super(SourceProcessor, self).FindFilesIn(path) |
304 | 304 |
305 def IsRelevant(self, name): | 305 def IsRelevant(self, name): |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 "two empty lines between declarations check..." | 426 "two empty lines between declarations check..." |
427 success = SourceProcessor().Run(workspace) and success | 427 success = SourceProcessor().Run(workspace) and success |
428 if success: | 428 if success: |
429 return 0 | 429 return 0 |
430 else: | 430 else: |
431 return 1 | 431 return 1 |
432 | 432 |
433 | 433 |
434 if __name__ == '__main__': | 434 if __name__ == '__main__': |
435 sys.exit(Main()) | 435 sys.exit(Main()) |
OLD | NEW |