| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # TODO(joaodasilva): remove this file. http://crbug.com/327345 | 5 # TODO(joaodasilva): remove this file. http://crbug.com/327345 |
| 6 | 6 |
| 7 import itertools | 7 import itertools |
| 8 | 8 |
| 9 def _CheckPolicyProtobufs(input_api, output_api): | 9 def _CheckPolicyProtobufs(input_api, output_api): |
| 10 # List of pairs (A, B) where A should equal B. | 10 # List of pairs (A, B) where A should equal B. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 'components/policy/proto/PRESUBMIT.py' ), | 25 'components/policy/proto/PRESUBMIT.py' ), |
| 26 ] | 26 ] |
| 27 | 27 |
| 28 root = input_api.change.RepositoryRoot() | 28 root = input_api.change.RepositoryRoot() |
| 29 results = [] | 29 results = [] |
| 30 | 30 |
| 31 for file_a, file_b in file_pairs: | 31 for file_a, file_b in file_pairs: |
| 32 path_a = input_api.os_path.join(root, *file_a.split('/')) | 32 path_a = input_api.os_path.join(root, *file_a.split('/')) |
| 33 path_b = input_api.os_path.join(root, *file_b.split('/')) | 33 path_b = input_api.os_path.join(root, *file_b.split('/')) |
| 34 with open(path_a, 'r') as f_a: | 34 with open(path_a, 'r') as f_a: |
| 35 content_a = f_a.read() | 35 content_a = f_a.readlines()[3:] |
| 36 with open(path_b, 'r') as f_b: | 36 with open(path_b, 'r') as f_b: |
| 37 content_b = f_b.read() | 37 content_b = f_b.readlines()[3:] |
| 38 if content_a != content_b: | 38 if content_a != content_b: |
| 39 # If you get this error then check |file_pairs| and make sure that the | 39 # If you get this error then check |file_pairs| and make sure that the |
| 40 # contents of the files in each pair match. | 40 # contents of the files in each pair match. |
| 41 results.append(output_api.PresubmitError( | 41 results.append(output_api.PresubmitError( |
| 42 '%s must equal %s. This is temporary until http://crbug.com/327345 ' | 42 '%s must equal %s. This is temporary until http://crbug.com/327345 ' |
| 43 'is fixed.' % (file_a, file_b))) | 43 'is fixed.' % (file_a, file_b))) |
| 44 | 44 |
| 45 # If new files are added then |file_pairs| must be updated. | 45 # If new files are added then |file_pairs| must be updated. |
| 46 existing = frozenset(itertools.chain(*file_pairs)) | 46 existing = frozenset(itertools.chain(*file_pairs)) |
| 47 for f in input_api.AffectedFiles(): | 47 for f in input_api.AffectedFiles(): |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 def _CommonChecks(input_api, output_api): | 58 def _CommonChecks(input_api, output_api): |
| 59 return _CheckPolicyProtobufs(input_api, output_api) | 59 return _CheckPolicyProtobufs(input_api, output_api) |
| 60 | 60 |
| 61 | 61 |
| 62 def CheckChangeOnUpload(input_api, output_api): | 62 def CheckChangeOnUpload(input_api, output_api): |
| 63 return _CommonChecks(input_api, output_api) | 63 return _CommonChecks(input_api, output_api) |
| 64 | 64 |
| 65 | 65 |
| 66 def CheckChangeOnCommit(input_api, output_api): | 66 def CheckChangeOnCommit(input_api, output_api): |
| 67 return _CommonChecks(input_api, output_api) | 67 return _CommonChecks(input_api, output_api) |
| OLD | NEW |