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

Side by Side Diff: PRESUBMIT.py

Issue 963553002: Automatically add NOTREECHECKS when uploading CLs from non master branches (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Addressing comments Created 5 years, 10 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
« 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 """
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 'one of: %s' % str(PUBLIC_API_OWNERS))) 241 'one of: %s' % str(PUBLIC_API_OWNERS)))
242 return results 242 return results
243 243
244 244
245 def PostUploadHook(cl, change, output_api): 245 def PostUploadHook(cl, change, output_api):
246 """git cl upload will call this hook after the issue is created/modified. 246 """git cl upload will call this hook after the issue is created/modified.
247 247
248 This hook does the following: 248 This hook does the following:
249 * Adds a link to preview docs changes if there are any docs changes in the CL. 249 * Adds a link to preview docs changes if there are any docs changes in the CL.
250 * Adds 'NOTRY=true' if the CL contains only docs changes. 250 * Adds 'NOTRY=true' if the CL contains only docs changes.
251 * Adds 'NOTREECHECKS=true' for non master branch changes since they do not
252 need to be gated on the master branch's tree.
253 * Adds 'NOTRY=true' for non master branch changes since trybots do not yet
254 work on them.
251 """ 255 """
252 256
253 results = [] 257 results = []
254 atleast_one_docs_change = False 258 atleast_one_docs_change = False
255 all_docs_changes = True 259 all_docs_changes = True
256 for affected_file in change.AffectedFiles(): 260 for affected_file in change.AffectedFiles():
257 affected_file_path = affected_file.LocalPath() 261 affected_file_path = affected_file.LocalPath()
258 file_path, _ = os.path.splitext(affected_file_path) 262 file_path, _ = os.path.splitext(affected_file_path)
259 if 'site' == file_path.split(os.path.sep)[0]: 263 if 'site' == file_path.split(os.path.sep)[0]:
260 atleast_one_docs_change = True 264 atleast_one_docs_change = True
261 else: 265 else:
262 all_docs_changes = False 266 all_docs_changes = False
263 if atleast_one_docs_change and not all_docs_changes: 267 if atleast_one_docs_change and not all_docs_changes:
264 break 268 break
265 269
266 issue = cl.issue 270 issue = cl.issue
267 rietveld_obj = cl.RpcServer() 271 rietveld_obj = cl.RpcServer()
268 if issue and rietveld_obj: 272 if issue and rietveld_obj:
269 original_description = rietveld_obj.get_description(issue) 273 original_description = rietveld_obj.get_description(issue)
270 new_description = original_description 274 new_description = original_description
271 275
272 # If the change includes only doc changes then add NOTRY=true in the 276 # If the change includes only doc changes then add NOTRY=true in the
273 # CL's description if it does not exist yet. 277 # CL's description if it does not exist yet.
274 if all_docs_changes and not re.search( 278 if all_docs_changes and not re.search(
275 r'^NOTRY=true$', original_description, re.M | re.I): 279 r'^NOTRY=true$', new_description, re.M | re.I):
276 new_description += '\nNOTRY=true' 280 new_description += '\nNOTRY=true'
277 results.append( 281 results.append(
278 output_api.PresubmitNotifyResult( 282 output_api.PresubmitNotifyResult(
279 'This change has only doc changes. Automatically added ' 283 'This change has only doc changes. Automatically added '
280 '\'NOTRY=true\' to the CL\'s description')) 284 '\'NOTRY=true\' to the CL\'s description'))
281 285
282 # If there is atleast one docs change then add preview link in the CL's 286 # If there is atleast one docs change then add preview link in the CL's
283 # description if it does not already exist there. 287 # description if it does not already exist there.
284 if atleast_one_docs_change and not re.search( 288 if atleast_one_docs_change and not re.search(
285 r'^DOCS_PREVIEW=.*', original_description, re.M | re.I): 289 r'^DOCS_PREVIEW=.*', new_description, re.M | re.I):
286 # Automatically add a link to where the docs can be previewed. 290 # Automatically add a link to where the docs can be previewed.
287 new_description += '\nDOCS_PREVIEW= %s%s' % (DOCS_PREVIEW_URL, issue) 291 new_description += '\nDOCS_PREVIEW= %s%s' % (DOCS_PREVIEW_URL, issue)
288 results.append( 292 results.append(
289 output_api.PresubmitNotifyResult( 293 output_api.PresubmitNotifyResult(
290 'Automatically added a link to preview the docs changes to the ' 294 'Automatically added a link to preview the docs changes to the '
291 'CL\'s description')) 295 'CL\'s description'))
292 296
297 # If the target ref is not master then add NOTREECHECKS=true and NOTRY=true
298 # to the CL's description if it does not already exist there.
299 target_ref = rietveld_obj.get_issue_properties(issue, False).get(
300 'target_ref', '')
301 if target_ref != 'refs/heads/master':
302 if not re.search(
303 r'^NOTREECHECKS=true$', new_description, re.M | re.I):
304 new_description += "\nNOTREECHECKS=true"
305 results.append(
306 output_api.PresubmitNotifyResult(
307 'Branch changes do not need to rely on the master branch\'s '
308 'tree status. Automatically added \'NOTREECHECKS=true\' to the '
309 'CL\'s description'))
310 if not re.search(
311 r'^NOTRY=true$', new_description, re.M | re.I):
312 new_description += "\nNOTRY=true"
313 results.append(
314 output_api.PresubmitNotifyResult(
315 'Trybots do not yet work for non-master branches. '
316 'Automatically added \'NOTRY=true\' to the CL\'s description'))
317
318
293 # If the description has changed update it. 319 # If the description has changed update it.
294 if new_description != original_description: 320 if new_description != original_description:
295 rietveld_obj.update_description(issue, new_description) 321 rietveld_obj.update_description(issue, new_description)
296 322
297 return results 323 return results
298 324
299 325
300 def CheckChangeOnCommit(input_api, output_api): 326 def CheckChangeOnCommit(input_api, output_api):
301 """Presubmit checks for the change on commit. 327 """Presubmit checks for the change on commit.
302 328
303 The following are the presubmit checks: 329 The following are the presubmit checks:
304 * Check change has one and only one EOL. 330 * Check change has one and only one EOL.
305 * Ensures that the Skia tree is open in 331 * Ensures that the Skia tree is open in
306 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' 332 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution'
307 state and an error if it is in 'Closed' state. 333 state and an error if it is in 'Closed' state.
308 """ 334 """
309 results = [] 335 results = []
310 results.extend(_CommonChecks(input_api, output_api)) 336 results.extend(_CommonChecks(input_api, output_api))
311 results.extend( 337 results.extend(
312 _CheckTreeStatus(input_api, output_api, json_url=( 338 _CheckTreeStatus(input_api, output_api, json_url=(
313 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) 339 SKIA_TREE_STATUS_URL + '/banner-status?format=json')))
314 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) 340 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api))
315 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) 341 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api))
316 return results 342 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