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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 if 'site' == file_path.split(os.path.sep)[0]: | 451 if 'site' == file_path.split(os.path.sep)[0]: |
452 atleast_one_docs_change = True | 452 atleast_one_docs_change = True |
453 else: | 453 else: |
454 all_docs_changes = False | 454 all_docs_changes = False |
455 if atleast_one_docs_change and not all_docs_changes: | 455 if atleast_one_docs_change and not all_docs_changes: |
456 break | 456 break |
457 | 457 |
458 issue = cl.issue | 458 issue = cl.issue |
459 if issue: | 459 if issue: |
460 original_description = cl.GetDescription() | 460 original_description = cl.GetDescription() |
| 461 changeIdLine = None |
| 462 if cl.IsGerrit(): |
| 463 # Remove Change-Id from description and add it back at the end. |
| 464 regex = re.compile(r'^(Change-Id: (\w+))(\n*)\Z', re.M | re.I) |
| 465 changeIdLine = re.search(regex, original_description).group(0) |
| 466 original_description = re.sub(regex, '', original_description) |
| 467 original_description = re.sub('\n+\Z', '\n', original_description) |
| 468 |
461 new_description = original_description | 469 new_description = original_description |
462 | 470 |
463 # Add GOLD_TRYBOT_URL if it does not exist yet. | 471 # Add GOLD_TRYBOT_URL if it does not exist yet. |
464 if not re.search(r'^GOLD_TRYBOT_URL=', new_description, re.M | re.I): | 472 if not re.search(r'^GOLD_TRYBOT_URL=', new_description, re.M | re.I): |
465 new_description += '\nGOLD_TRYBOT_URL= %s%s' % (GOLD_TRYBOT_URL, issue) | 473 new_description += '\nGOLD_TRYBOT_URL= %s%s' % (GOLD_TRYBOT_URL, issue) |
466 results.append( | 474 results.append( |
467 output_api.PresubmitNotifyResult( | 475 output_api.PresubmitNotifyResult( |
468 'Added link to Gold trybot runs to the CL\'s description.\n' | 476 'Added link to Gold trybot runs to the CL\'s description.\n' |
469 'Note: Results may take sometime to be populated after trybots ' | 477 'Note: Results may take sometime to be populated after trybots ' |
470 'complete.')) | 478 'complete.')) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 'Your CL modifies the path %s.\nAutomatically adding %s to ' | 536 'Your CL modifies the path %s.\nAutomatically adding %s to ' |
529 'the CL description.' % (affected_file_path, extra_bots))) | 537 'the CL description.' % (affected_file_path, extra_bots))) |
530 _MergeCQExtraTrybotsMaps( | 538 _MergeCQExtraTrybotsMaps( |
531 cq_master_to_trybots, _GetCQExtraTrybotsMap(extra_bots)) | 539 cq_master_to_trybots, _GetCQExtraTrybotsMap(extra_bots)) |
532 if cq_master_to_trybots: | 540 if cq_master_to_trybots: |
533 new_description = _AddCQExtraTrybotsToDesc( | 541 new_description = _AddCQExtraTrybotsToDesc( |
534 cq_master_to_trybots, new_description) | 542 cq_master_to_trybots, new_description) |
535 | 543 |
536 # If the description has changed update it. | 544 # If the description has changed update it. |
537 if new_description != original_description: | 545 if new_description != original_description: |
| 546 if changeIdLine: |
| 547 # The Change-Id line must have two newlines before it. |
| 548 new_description += '\n\n' + changeIdLine |
538 cl.UpdateDescription(new_description) | 549 cl.UpdateDescription(new_description) |
539 | 550 |
540 return results | 551 return results |
541 | 552 |
542 | 553 |
543 def _AddCQExtraTrybotsToDesc(cq_master_to_trybots, description): | 554 def _AddCQExtraTrybotsToDesc(cq_master_to_trybots, description): |
544 """Adds the specified master and trybots to the CQ_INCLUDE_TRYBOTS keyword. | 555 """Adds the specified master and trybots to the CQ_INCLUDE_TRYBOTS keyword. |
545 | 556 |
546 If the keyword already exists in the description then it appends to it only | 557 If the keyword already exists in the description then it appends to it only |
547 if the specified values do not already exist. | 558 if the specified values do not already exist. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 state and an error if it is in 'Closed' state. | 606 state and an error if it is in 'Closed' state. |
596 """ | 607 """ |
597 results = [] | 608 results = [] |
598 results.extend(_CommonChecks(input_api, output_api)) | 609 results.extend(_CommonChecks(input_api, output_api)) |
599 results.extend( | 610 results.extend( |
600 _CheckTreeStatus(input_api, output_api, json_url=( | 611 _CheckTreeStatus(input_api, output_api, json_url=( |
601 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 612 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
602 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 613 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
603 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) | 614 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) |
604 return results | 615 return results |
OLD | NEW |