Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: appengine/monorail/sql/PRESUBMIT.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/monorail/sitewide/userupdates.py ('k') | appengine/monorail/sql/alter-table-log.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/sql/PRESUBMIT.py
diff --git a/appengine/monorail/sql/PRESUBMIT.py b/appengine/monorail/sql/PRESUBMIT.py
new file mode 100644
index 0000000000000000000000000000000000000000..a0fb30f41a0e82dc62efce4454ac5bdcd756184b
--- /dev/null
+++ b/appengine/monorail/sql/PRESUBMIT.py
@@ -0,0 +1,32 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Presubmit script just for Monorail's SQL files."""
+
+
+def AlterTableCheck(input_api, output_api): # pragma: no cover
+ this_dir = input_api.PresubmitLocalPath()
+ sql_files = set(x for x in input_api.os_listdir(this_dir)
+ if (x.endswith('.sql') and x != 'queries.sql'))
+ log_file = input_api.os_path.join(this_dir, 'alter-table-log.txt')
+ affected_files = set(f.LocalPath() for f in input_api.AffectedTextFiles())
+
+ if (any(f in affected_files for f in sql_files) ^
+ (log_file in affected_files)):
+ return [output_api.PresubmitPromptOrNotify(
+ 'It looks like you have modified the sql schema without updating\n'
+ 'the alter-table-log, or vice versa. Are you sure you want to do this?')
+ ]
+ return []
+
+
+def CheckChangeOnUpload(input_api, output_api): # pragma: no cover
+ output = AlterTableCheck(input_api, output_api)
+ return output
+
+
+def CheckChangeOnCommit(input_api, output_api): # pragma: no cover
+ output = AlterTableCheck(input_api, output_api)
+ return output
« no previous file with comments | « appengine/monorail/sitewide/userupdates.py ('k') | appengine/monorail/sql/alter-table-log.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698