| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | |
| 6 def CheckChangeOnUpload(input_api, output_api): | 5 def CheckChangeOnUpload(input_api, output_api): |
| 7 """Warn when changing md_history without vulcanizing.""" | 6 return input_api.canned_checks.CheckPatchFormatted( |
| 8 | 7 input_api, output_api, check_js=True) |
| 9 def _is_history_source_file(file): | |
| 10 path = file.LocalPath() | |
| 11 return (not path.endswith('externs.js') and | |
| 12 not path.endswith('crisper.js') and | |
| 13 not path.endswith('vulcanized.html') and | |
| 14 (path.endswith('.js') or path.endswith('.html'))) | |
| 15 | |
| 16 os_path = input_api.os_path | |
| 17 earliest_vulcanize_change = min(os_path.getmtime(x) for x in | |
| 18 ['app.vulcanized.html', | |
| 19 'app.crisper.js', | |
| 20 'lazy_load.vulcanized.html', | |
| 21 'lazy_load.crisper.js']) | |
| 22 | |
| 23 source_files = input_api.AffectedFiles(file_filter=_is_history_source_file) | |
| 24 latest_history_change = 0 | |
| 25 if source_files: | |
| 26 latest_history_change = max( | |
| 27 os_path.getmtime(os_path.basename(f.LocalPath())) for f in source_files) | |
| 28 | |
| 29 if latest_history_change > earliest_vulcanize_change: | |
| 30 return [output_api.PresubmitPromptWarning( | |
| 31 'Vulcanize must be run when changing files in md_history. See ' | |
| 32 'docs/vulcanize.md.')] | |
| 33 return [] | |
| OLD | NEW |