OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is govered by a BSD-style |
| 3 # license that can be found in the LICENSE file or at |
| 4 # https://developers.google.com/open-source/licenses/bsd |
| 5 |
| 6 """Presubmit script just for Monorail's SQL files.""" |
| 7 |
| 8 |
| 9 def AlterTableCheck(input_api, output_api): # pragma: no cover |
| 10 this_dir = input_api.PresubmitLocalPath() |
| 11 sql_files = set(x for x in input_api.os_listdir(this_dir) |
| 12 if (x.endswith('.sql') and x != 'queries.sql')) |
| 13 log_file = input_api.os_path.join(this_dir, 'alter-table-log.txt') |
| 14 affected_files = set(f.LocalPath() for f in input_api.AffectedTextFiles()) |
| 15 |
| 16 if (any(f in affected_files for f in sql_files) ^ |
| 17 (log_file in affected_files)): |
| 18 return [output_api.PresubmitPromptOrNotify( |
| 19 'It looks like you have modified the sql schema without updating\n' |
| 20 'the alter-table-log, or vice versa. Are you sure you want to do this?') |
| 21 ] |
| 22 return [] |
| 23 |
| 24 |
| 25 def CheckChangeOnUpload(input_api, output_api): # pragma: no cover |
| 26 output = AlterTableCheck(input_api, output_api) |
| 27 return output |
| 28 |
| 29 |
| 30 def CheckChangeOnCommit(input_api, output_api): # pragma: no cover |
| 31 output = AlterTableCheck(input_api, output_api) |
| 32 return output |
OLD | NEW |