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 """ |
11 | 11 |
| 12 import csv |
12 import fnmatch | 13 import fnmatch |
13 import os | 14 import os |
14 import re | 15 import re |
15 import subprocess | 16 import subprocess |
16 import sys | 17 import sys |
17 import traceback | 18 import traceback |
18 | 19 |
19 | 20 |
20 REVERT_CL_SUBJECT_PREFIX = 'Revert ' | 21 REVERT_CL_SUBJECT_PREFIX = 'Revert ' |
21 | 22 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 'tree status. Automatically added \'NOTREECHECKS=true\' to the ' | 356 'tree status. Automatically added \'NOTREECHECKS=true\' to the ' |
356 'CL\'s description')) | 357 'CL\'s description')) |
357 if not re.search( | 358 if not re.search( |
358 r'^NOTRY=true$', new_description, re.M | re.I): | 359 r'^NOTRY=true$', new_description, re.M | re.I): |
359 new_description += "\nNOTRY=true" | 360 new_description += "\nNOTRY=true" |
360 results.append( | 361 results.append( |
361 output_api.PresubmitNotifyResult( | 362 output_api.PresubmitNotifyResult( |
362 'Trybots do not yet work for non-master branches. ' | 363 'Trybots do not yet work for non-master branches. ' |
363 'Automatically added \'NOTRY=true\' to the CL\'s description')) | 364 'Automatically added \'NOTRY=true\' to the CL\'s description')) |
364 | 365 |
| 366 # Read and process the HASHTAGS file. |
| 367 with open('HASHTAGS', 'rb') as hashtags_csv: |
| 368 hashtags_reader = csv.reader(hashtags_csv, delimiter=',') |
| 369 for row in hashtags_reader: |
| 370 if not row or row[0].startswith('#'): |
| 371 # Ignore empty lines and comments |
| 372 continue |
| 373 hashtag = row[0] |
| 374 mapped_text = row[1] |
| 375 # Search for the hashtag in the description. |
| 376 if re.search('#%s' % hashtag, new_description, re.M | re.I): |
| 377 # Add the mapped text if it does not already exist in the description. |
| 378 if not re.search(r'^%s$' % mapped_text, new_description, re.M | re.I): |
| 379 new_description += '\n%s' % mapped_text |
| 380 results.append( |
| 381 output_api.PresubmitNotifyResult( |
| 382 'Found \'#%s\', automatically added \'%s\' to the CL\'s ' |
| 383 'description' % (hashtag, mapped_text))) |
365 | 384 |
366 # If the description has changed update it. | 385 # If the description has changed update it. |
367 if new_description != original_description: | 386 if new_description != original_description: |
368 rietveld_obj.update_description(issue, new_description) | 387 rietveld_obj.update_description(issue, new_description) |
369 | 388 |
370 return results | 389 return results |
371 | 390 |
372 | 391 |
373 def CheckChangeOnCommit(input_api, output_api): | 392 def CheckChangeOnCommit(input_api, output_api): |
374 """Presubmit checks for the change on commit. | 393 """Presubmit checks for the change on commit. |
375 | 394 |
376 The following are the presubmit checks: | 395 The following are the presubmit checks: |
377 * Check change has one and only one EOL. | 396 * Check change has one and only one EOL. |
378 * Ensures that the Skia tree is open in | 397 * Ensures that the Skia tree is open in |
379 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' | 398 http://skia-tree-status.appspot.com/. Shows a warning if it is in 'Caution' |
380 state and an error if it is in 'Closed' state. | 399 state and an error if it is in 'Closed' state. |
381 """ | 400 """ |
382 results = [] | 401 results = [] |
383 results.extend(_CommonChecks(input_api, output_api)) | 402 results.extend(_CommonChecks(input_api, output_api)) |
384 results.extend( | 403 results.extend( |
385 _CheckTreeStatus(input_api, output_api, json_url=( | 404 _CheckTreeStatus(input_api, output_api, json_url=( |
386 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) | 405 SKIA_TREE_STATUS_URL + '/banner-status?format=json'))) |
387 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) | 406 results.extend(_CheckLGTMsForPublicAPI(input_api, output_api)) |
388 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) | 407 results.extend(_CheckOwnerIsInAuthorsFile(input_api, output_api)) |
389 return results | 408 return results |
OLD | NEW |