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

Unified Diff: PRESUBMIT.py

Issue 3015033: Create a PRESUBMIT which verifies that 9999 and stable are in sync (Closed) Base URL: http://src.chromium.org/git/chromiumos-overlay.git
Patch Set: Created 10 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
new file mode 100644
index 0000000000000000000000000000000000000000..934f4660fd47132d512b9a0d1ae03689596d295b
--- /dev/null
+++ b/PRESUBMIT.py
@@ -0,0 +1,69 @@
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Top-level presubmit script for Chromium OS.
+
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details about the presubmit API built into gcl and git cl.
+"""
+
+import difflib
+import os
+
+_EBUILD_FILES = (
+ r".*\.ebuild",
+)
+
+def _IsCrosWorkonEbuild(ebuild_contents):
+ return ebuild_contents.count('inherit cros-workon') > 0
sosa 2010/07/27 00:30:38 What happens if an ebuild contains "inherit someth
+
+def Check9999Updated(input_api, output_api, source_file_filter=None):
+ """Checks that the 9999 ebuild was also modified."""
+ output = []
+ inconsistent = []
+ missing_9999 = set()
+ for f in input_api.AffectedSourceFiles(source_file_filter):
+ ebuild_contents = f.NewContents()
+ # only look at non-9999
+ if f.LocalPath().endswith('-9999.ebuild'):
+ continue
+ if _IsCrosWorkonEbuild(ebuild_contents):
+ dir = os.path.dirname(f.AbsoluteLocalPath())
+ ebuild = os.path.basename(dir)
+ devebuild_path = os.path.join(dir, ebuild + '-9999.ebuild')
Chris Masone 2010/07/26 22:23:33 will this work if I have chromeos-login-0.5.0.ebui
+ # check if 9999 ebuild exists
+ if not os.path.isfile(devebuild_path):
+ missing_9999.add(ebuild)
+ continue
+ diff = difflib.ndiff(ebuild_contents,
+ open(devebuild_path).read().splitlines())
+ for line in diff:
+ if line.startswith('+') or line.startswith('-'):
+ # ignore empty-lines
+ if len(line) == 2:
+ continue
+ if not (line[2:].startswith('KEYWORDS=') or
+ line[2:].startswith('CROS_WORKON_COMMIT=')):
+ inconsistent.append(f.LocalPath())
+
+ if missing_9999:
+ output.append(output_api.PresubmitPromptWarning(
+ 'Missing 9999 for these cros-workon ebuilds:', items=missing_9999))
+ if inconsistent:
+ output.append(output_api.PresubmitPromptWarning(
+ 'Following ebuilds are inconsistent with 9999:', items=inconsistent))
+ return output
+
+def CheckChange(input_api, output_api, committing):
+ ebuilds = lambda x: input_api.FilterSourceFile(x, white_list=_EBUILD_FILES)
+ results = []
+ results += Check9999Updated(input_api, output_api,
+ source_file_filter=ebuilds)
+ return results
+
+def CheckChangeOnUpload(input_api, output_api):
+ return CheckChange(input_api, output_api, False)
+
+def CheckChangeOnCommit(input_api, output_api):
+ return CheckChange(input_api, output_api, True)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698