| OLD | NEW |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
| 2 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) | 2 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) |
| 3 # Copyright (C) 2010 ProFUSION embedded systems | 3 # Copyright (C) 2010 ProFUSION embedded systems |
| 4 # | 4 # |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
| 7 # met: | 7 # met: |
| 8 # | 8 # |
| 9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 | 42 |
| 43 class PatchReader(object): | 43 class PatchReader(object): |
| 44 """Supports checking style in patches.""" | 44 """Supports checking style in patches.""" |
| 45 | 45 |
| 46 def __init__(self, text_file_reader): | 46 def __init__(self, text_file_reader): |
| 47 """Create a PatchReader instance. | 47 """Create a PatchReader instance. |
| 48 | 48 |
| 49 Args: | 49 Args: |
| 50 text_file_reader: A TextFileReader instance. | 50 text_file_reader: A TextFileReader instance. |
| 51 | |
| 52 """ | 51 """ |
| 53 self._text_file_reader = text_file_reader | 52 self._text_file_reader = text_file_reader |
| 54 | 53 |
| 55 def check(self, patch_string, fs=None): | 54 def check(self, patch_string, fs=None): |
| 56 """Check style in the given patch.""" | 55 """Check style in the given patch.""" |
| 57 fs = fs or FileSystem() | 56 fs = fs or FileSystem() |
| 58 patch_files = DiffParser(patch_string.splitlines()).files | 57 patch_files = DiffParser(patch_string.splitlines()).files |
| 59 | 58 |
| 60 # If the user uses git, checking subversion config file only once is eno
ugh. | 59 # If the user uses git, checking subversion config file only once is eno
ugh. |
| 61 call_only_once = True | 60 call_only_once = True |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 if detection.display_name() == "git": | 73 if detection.display_name() == "git": |
| 75 call_only_once = False | 74 call_only_once = False |
| 76 continue | 75 continue |
| 77 # Don't check files which contain only deleted lines | 76 # Don't check files which contain only deleted lines |
| 78 # as they can never add style errors. However, mark them as | 77 # as they can never add style errors. However, mark them as |
| 79 # processed so that we count up number of such files. | 78 # processed so that we count up number of such files. |
| 80 self._text_file_reader.count_delete_only_file() | 79 self._text_file_reader.count_delete_only_file() |
| 81 continue | 80 continue |
| 82 | 81 |
| 83 self._text_file_reader.process_file(file_path=path, line_numbers=lin
e_numbers) | 82 self._text_file_reader.process_file(file_path=path, line_numbers=lin
e_numbers) |
| OLD | NEW |