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

Side by Side Diff: PRESUBMIT.py

Issue 22453004: If any change is made to the public API then make sure there is an LGTM from an owner (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 """Top-level presubmit script for Skia. 6 """Top-level presubmit script for Skia.
7 7
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
9 for more details about the presubmit API built into gcl. 9 for more details about the presubmit API built into gcl.
10 """ 10 """
11 11
12 import os 12 import os
13 import sys 13 import sys
14 14
15 15
16 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com' 16 SKIA_TREE_STATUS_URL = 'http://skia-tree-status.appspot.com'
17 17
18 PUBLIC_API_OWNERS = (
19 'reed@chromium.org',
20 'reed@google.com',
21 'bsalomon@chromium.org',
22 'bsalomon@google.com',
23 )
24
18 25
19 def _CheckChangeHasEol(input_api, output_api, source_file_filter=None): 26 def _CheckChangeHasEol(input_api, output_api, source_file_filter=None):
20 """Checks that files end with atleast one \n (LF).""" 27 """Checks that files end with atleast one \n (LF)."""
21 eof_files = [] 28 eof_files = []
22 for f in input_api.AffectedSourceFiles(source_file_filter): 29 for f in input_api.AffectedSourceFiles(source_file_filter):
23 contents = input_api.ReadFile(f, 'rb') 30 contents = input_api.ReadFile(f, 'rb')
24 # Check that the file ends in atleast one newline character. 31 # Check that the file ends in atleast one newline character.
25 if len(contents) > 1 and contents[-1:] != '\n': 32 if len(contents) > 1 and contents[-1:] != '\n':
26 eof_files.append(f.LocalPath()) 33 eof_files.append(f.LocalPath())
27 34
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 SKIA_TREE_STATUS_URL + '/current-sheriff') 96 SKIA_TREE_STATUS_URL + '/current-sheriff')
90 sheriff_details = input_api.json.loads(connection.read()) 97 sheriff_details = input_api.json.loads(connection.read())
91 if sheriff_details: 98 if sheriff_details:
92 tree_status_results[0]._message += ( 99 tree_status_results[0]._message += (
93 '\n\nPlease contact the current Skia sheriff (%s) if you are trying ' 100 '\n\nPlease contact the current Skia sheriff (%s) if you are trying '
94 'to submit a build fix\nand do not know how to submit because the ' 101 'to submit a build fix\nand do not know how to submit because the '
95 'tree is closed') % sheriff_details['username'] 102 'tree is closed') % sheriff_details['username']
96 return tree_status_results 103 return tree_status_results
97 104
98 105
106 def _CheckLGTMsForPublicAPI(input_api, output_api):
107 """Check LGTMs for public API changes.
108
109 For public API files make sure there is an LGTM from the list of owners in
110 PUBLIC_API_OWNERS.
111 """
112 results = []
113 requires_owner_check = False
114 for affected_svn_file in input_api.AffectedFiles():
115 affected_file_path = affected_svn_file.AbsoluteLocalPath()
116 file_path, file_ext = os.path.splitext(affected_file_path)
117 # We only care about files that end in .h and are under the include dir.
118 if file_ext == '.h' and 'include' in file_path.split(os.path.sep):
119 requires_owner_check = True
120
121 if not requires_owner_check:
122 return results
123
124 lgtm_from_owner = False
125 issue = input_api.change.issue
126 if issue and input_api.rietveld:
127 issue_properties = input_api.rietveld.get_issue_properties(
128 issue=int(issue), messages=True)
129 if issue_properties['owner_email'] in PUBLIC_API_OWNERS:
130 # An owner created the CL that is an automatic LGTM.
131 lgtm_from_owner = True
132
133 messages = issue_properties.get('messages')
134 if messages:
135 for message in messages:
136 if (message['sender'] in PUBLIC_API_OWNERS and
137 'lgtm' in message['text'].lower()):
138 # Found an lgtm in a message from an owner.
139 lgtm_from_owner = True
140 break;
141
142 if not lgtm_from_owner:
143 results.append(
144 output_api.PresubmitError(
145 'Since the CL is editing public API, you must have an LGTM from '
146 'one of: %s' % str(PUBLIC_API_OWNERS)))
147 return results
148
149
99 def CheckChangeOnCommit(input_api, output_api): 150 def CheckChangeOnCommit(input_api, output_api):
100 """Presubmit checks for the change on commit. 151 """Presubmit checks for the change on commit.
101 152
102 The following are the presubmit checks: 153 The following are the presubmit checks:
103 * Check change has one and only one EOL. 154 * Check change has one and only one EOL.
104 * Ensures that the Skia tree is open in 155 * Ensures that the Skia tree is open in
105 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' 156 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution'
106 state and an error if it is in 'Closed' state. 157 state and an error if it is in 'Closed' state.
107 """ 158 """
108 results = [] 159 results = []
109 results.extend(_CommonChecks(input_api, output_api)) 160 results.extend(_CommonChecks(input_api, output_api))
110 results.extend( 161 results.extend(
111 _CheckTreeStatus(input_api, output_api, json_url=( 162 _CheckTreeStatus(input_api, output_api, json_url=(
112 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) 163 SKIA_TREE_STATUS_URL + '/banner-status?format=json')))
164 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api))
113 return results 165 return results
OLDNEW
« 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