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

Unified Diff: tools/metrics/histograms/PRESUBMIT.py

Issue 13245008: Open-source histograms.xml, starting with Autofill histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
Index: tools/metrics/histograms/PRESUBMIT.py
diff --git a/tools/metrics/histograms/PRESUBMIT.py b/tools/metrics/histograms/PRESUBMIT.py
new file mode 100644
index 0000000000000000000000000000000000000000..76ac0d22dead0b1b474da82b805efeee014c8d5d
--- /dev/null
+++ b/tools/metrics/histograms/PRESUBMIT.py
@@ -0,0 +1,39 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details on the presubmit API built into gcl.
+"""
+
+
+def CheckChange(input_api, output_api):
+ """Checks that histograms.xml is pretty-printed and well-formatted."""
+ for f in input_api.AffectedTextFiles():
+ p = f.AbsoluteLocalPath()
+ if (input_api.basename(p) == 'histograms.xml'
+ and input_api.os_path.dirname(p) == input_api.PresubmitLocalPath()):
+ cwd = input_api.os_path.dirname(p)
+ exit_code = input_api.subprocess.call(
+ ['python', 'pretty_print.py', '--presubmit'], cwd=cwd)
+ if exit_code != 0:
+ return [output_api.PresubmitError(
+ 'histograms.xml is not formatted correctly; run pretty_print.py '
+ 'to fix')]
+
+ exit_code = input_api.subprocess.call(
+ ['python', 'validate_format.py'], cwd=cwd)
+ if exit_code != 0:
+ return [output_api.PresubmitError(
+ 'histograms.xml is not well formatted; run update_descriptions.py '
+ 'and fix the reported errors')]
+ return []
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ return CheckChange(input_api, output_api)
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ return CheckChange(input_api, output_api)

Powered by Google App Engine
This is Rietveld 408576698