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

Side by Side Diff: chrome/browser/chromeos/policy/proto/PRESUBMIT.py

Issue 108563005: Move the cloud policy protobufs into the component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 # TODO(joaodasilva): remove this file. http://crbug.com/327345
6
7 import itertools
8
9 def _CheckPolicyProtobufs(input_api, output_api):
10 # List of pairs (A, B) where A should equal B.
11 file_pairs = [
12 ( 'chrome/browser/policy/proto/chromeos/chrome_device_policy.proto',
13 'chrome/browser/chromeos/policy/proto/chrome_device_policy.proto' ),
14 ( 'chrome/browser/policy/proto/chromeos/install_attributes.proto',
15 'chrome/browser/chromeos/policy/proto/install_attributes.proto' ),
16 ( 'chrome/browser/policy/proto/cloud/chrome_extension_policy.proto',
17 'components/policy/proto/chrome_extension_policy.proto' ),
18 ( 'chrome/browser/policy/proto/cloud/device_management_backend.proto',
19 'components/policy/proto/device_management_backend.proto' ),
20 ( 'chrome/browser/policy/proto/cloud/device_management_local.proto',
21 'components/policy/proto/device_management_local.proto' ),
22 ( 'chrome/browser/policy/proto/PRESUBMIT.py',
23 'components/policy/proto/PRESUBMIT.py' ),
24 ( 'chrome/browser/chromeos/policy/proto/PRESUBMIT.py',
25 'components/policy/proto/PRESUBMIT.py' ),
26 ]
27
28 root = input_api.change.RepositoryRoot()
29 results = []
30
31 for file_a, file_b in file_pairs:
32 path_a = input_api.os_path.join(root, *file_a.split('/'))
33 path_b = input_api.os_path.join(root, *file_b.split('/'))
34 with open(path_a, 'r') as f_a:
35 content_a = f_a.read()
36 with open(path_b, 'r') as f_b:
37 content_b = f_b.read()
38 if content_a != content_b:
39 # If you get this error then check |file_pairs| and make sure that the
40 # contents of the files in each pair match.
41 results.append(output_api.PresubmitError(
42 '%s must equal %s. This is temporary until http://crbug.com/327345 '
43 'is fixed.' % (file_a, file_b)))
44
45 # If new files are added then |file_pairs| must be updated.
46 existing = frozenset(itertools.chain(*file_pairs))
47 for f in input_api.AffectedFiles():
48 if f.LocalPath() not in existing:
49 # If you get this error then add an entry for the new files to
50 # |file_pairs|.
51 results.append(output_api.PresubmitError(
52 'Please add an entry for %s to %s/PRESUBMIT.py' %
53 (f.LocalPath(), input_api.PresubmitLocalPath())))
54
55 return results
56
57
58 def _CommonChecks(input_api, output_api):
59 return _CheckPolicyProtobufs(input_api, output_api)
60
61
62 def CheckChangeOnUpload(input_api, output_api):
63 return _CommonChecks(input_api, output_api)
64
65
66 def CheckChangeOnCommit(input_api, output_api):
67 return _CommonChecks(input_api, output_api)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698