| OLD | NEW |
| 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 affected_file_path = affected_file.LocalPath() | 455 affected_file_path = affected_file.LocalPath() |
| 456 file_path, _ = os.path.splitext(affected_file_path) | 456 file_path, _ = os.path.splitext(affected_file_path) |
| 457 if 'site' == file_path.split(os.path.sep)[0]: | 457 if 'site' == file_path.split(os.path.sep)[0]: |
| 458 atleast_one_docs_change = True | 458 atleast_one_docs_change = True |
| 459 else: | 459 else: |
| 460 all_docs_changes = False | 460 all_docs_changes = False |
| 461 if atleast_one_docs_change and not all_docs_changes: | 461 if atleast_one_docs_change and not all_docs_changes: |
| 462 break | 462 break |
| 463 | 463 |
| 464 issue = cl.issue | 464 issue = cl.issue |
| 465 rietveld_obj = cl.RpcServer() | 465 if issue: |
| 466 if issue and rietveld_obj: | 466 original_description = cl.GetDescription() |
| 467 original_description = rietveld_obj.get_description(issue) | |
| 468 new_description = original_description | 467 new_description = original_description |
| 469 | 468 |
| 470 # Add GOLD_TRYBOT_URL if it does not exist yet. | 469 # Add GOLD_TRYBOT_URL if it does not exist yet. |
| 471 if not re.search(r'^GOLD_TRYBOT_URL=', new_description, re.M | re.I): | 470 if not re.search(r'^GOLD_TRYBOT_URL=', new_description, re.M | re.I): |
| 472 new_description += '\nGOLD_TRYBOT_URL= %s%s' % (GOLD_TRYBOT_URL, issue) | 471 new_description += '\nGOLD_TRYBOT_URL= %s%s' % (GOLD_TRYBOT_URL, issue) |
| 473 results.append( | 472 results.append( |
| 474 output_api.PresubmitNotifyResult( | 473 output_api.PresubmitNotifyResult( |
| 475 'Added link to Gold trybot runs to the CL\'s description.\n' | 474 'Added link to Gold trybot runs to the CL\'s description.\n' |
| 476 'Note: Results may take sometime to be populated after trybots ' | 475 'Note: Results may take sometime to be populated after trybots ' |
| 477 'complete.')) | 476 'complete.')) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 492 r'^DOCS_PREVIEW=.*', new_description, re.M | re.I): | 491 r'^DOCS_PREVIEW=.*', new_description, re.M | re.I): |
| 493 # Automatically add a link to where the docs can be previewed. | 492 # Automatically add a link to where the docs can be previewed. |
| 494 new_description += '\nDOCS_PREVIEW= %s%s' % (DOCS_PREVIEW_URL, issue) | 493 new_description += '\nDOCS_PREVIEW= %s%s' % (DOCS_PREVIEW_URL, issue) |
| 495 results.append( | 494 results.append( |
| 496 output_api.PresubmitNotifyResult( | 495 output_api.PresubmitNotifyResult( |
| 497 'Automatically added a link to preview the docs changes to the ' | 496 'Automatically added a link to preview the docs changes to the ' |
| 498 'CL\'s description')) | 497 'CL\'s description')) |
| 499 | 498 |
| 500 # If the target ref is not master then add NOTREECHECKS=true and NOTRY=true | 499 # If the target ref is not master then add NOTREECHECKS=true and NOTRY=true |
| 501 # to the CL's description if it does not already exist there. | 500 # to the CL's description if it does not already exist there. |
| 502 target_ref = rietveld_obj.get_issue_properties(issue, False).get( | 501 target_ref = cl.GetRemoteBranch()[1] |
| 503 'target_ref', '') | 502 if target_ref != 'refs/remotes/origin/master': |
| 504 if target_ref != 'refs/heads/master': | |
| 505 if not re.search( | 503 if not re.search( |
| 506 r'^NOTREECHECKS=true$', new_description, re.M | re.I): | 504 r'^NOTREECHECKS=true$', new_description, re.M | re.I): |
| 507 new_description += "\nNOTREECHECKS=true" | 505 new_description += "\nNOTREECHECKS=true" |
| 508 results.append( | 506 results.append( |
| 509 output_api.PresubmitNotifyResult( | 507 output_api.PresubmitNotifyResult( |
| 510 'Branch changes do not need to rely on the master branch\'s ' | 508 'Branch changes do not need to rely on the master branch\'s ' |
| 511 'tree status. Automatically added \'NOTREECHECKS=true\' to the ' | 509 'tree status. Automatically added \'NOTREECHECKS=true\' to the ' |
| 512 'CL\'s description')) | 510 'CL\'s description')) |
| 513 if not re.search( | 511 if not re.search( |
| 514 r'^NOTRY=true$', new_description, re.M | re.I): | 512 r'^NOTRY=true$', new_description, re.M | re.I): |
| (...skipping 21 matching lines...) Expand all Loading... |
| 536 'Your CL modifies the path %s.\nAutomatically adding %s to ' | 534 'Your CL modifies the path %s.\nAutomatically adding %s to ' |
| 537 'the CL description.' % (affected_file_path, extra_bots))) | 535 'the CL description.' % (affected_file_path, extra_bots))) |
| 538 _MergeCQExtraTrybotsMaps( | 536 _MergeCQExtraTrybotsMaps( |
| 539 cq_master_to_trybots, _GetCQExtraTrybotsMap(extra_bots)) | 537 cq_master_to_trybots, _GetCQExtraTrybotsMap(extra_bots)) |
| 540 if cq_master_to_trybots: | 538 if cq_master_to_trybots: |
| 541 new_description = _AddCQExtraTrybotsToDesc( | 539 new_description = _AddCQExtraTrybotsToDesc( |
| 542 cq_master_to_trybots, new_description) | 540 cq_master_to_trybots, new_description) |
| 543 | 541 |
| 544 # If the description has changed update it. | 542 # If the description has changed update it. |
| 545 if new_description != original_description: | 543 if new_description != original_description: |
| 546 rietveld_obj.update_description(issue, new_description) | 544 cl.UpdateDescription(new_description) |
| 547 | 545 |
| 548 return results | 546 return results |
| 549 | 547 |
| 550 | 548 |
| 551 def _AddCQExtraTrybotsToDesc(cq_master_to_trybots, description): | 549 def _AddCQExtraTrybotsToDesc(cq_master_to_trybots, description): |
| 552 """Adds the specified master and trybots to the CQ_INCLUDE_TRYBOTS keyword. | 550 """Adds the specified master and trybots to the CQ_INCLUDE_TRYBOTS keyword. |
| 553 | 551 |
| 554 If the keyword already exists in the description then it appends to it only | 552 If the keyword already exists in the description then it appends to it only |
| 555 if the specified values do not already exist. | 553 if the specified values do not already exist. |
| 556 If the keyword does not exist then it creates a new section in the | 554 If the keyword does not exist then it creates a new section in the |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 state and an error if it is in 'Closed' state. | 601 state and an error if it is in 'Closed' state. |
| 604 """ | 602 """ |
| 605 results = [] | 603 results = [] |
| 606 results.extend(_CommonChecks(input_api, output_api)) | 604 results.extend(_CommonChecks(input_api, output_api)) |
| 607 results.extend( | 605 results.extend( |
| 608 _CheckTreeStatus(input_api, output_api, json_url=( | 606 _CheckTreeStatus(input_api, output_api, json_url=( |
| 609 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 607 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
| 610 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 608 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
| 611 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) | 609 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) |
| 612 return results | 610 return results |
| OLD | NEW |