| 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 """Handler for chrome/app/policy/policy_templates.json | 5 """Handler for chrome/app/policy/policy_templates.json |
| 6 | 6 |
| 7 This handler examines changes to the policy_templates.json file and posts | 7 This handler examines changes to the policy_templates.json file and posts |
| 8 comments with checklists for the patch author and reviewer to go through to | 8 comments with checklists for the patch author and reviewer to go through to |
| 9 avoid common pitfalls. | 9 avoid common pitfalls. |
| 10 """ | 10 """ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 REVIEW_MESSAGE_TEMPLATE = 'review_message.txt' | 25 REVIEW_MESSAGE_TEMPLATE = 'review_message.txt' |
| 26 ADDITION_COMMENT_TEMPLATE = 'addition_comment.txt' | 26 ADDITION_COMMENT_TEMPLATE = 'addition_comment.txt' |
| 27 MODIFICATION_COMMENT_TEMPLATE = 'modification_comment.txt' | 27 MODIFICATION_COMMENT_TEMPLATE = 'modification_comment.txt' |
| 28 | 28 |
| 29 | 29 |
| 30 JINJA_ENVIRONMENT = jinja2.Environment( | 30 JINJA_ENVIRONMENT = jinja2.Environment( |
| 31 loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) | 31 loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) |
| 32 | 32 |
| 33 | 33 |
| 34 def prepare_address_list(addr, email_list): |
| 35 """Prepares |email_list| for use as rietveld query parameter. |
| 36 |
| 37 Canonicalizes the entries in |email_list|, removes any occurrences of |addr|, |
| 38 joins the entries with commas and returns the result. |
| 39 """ |
| 40 return ','.join([util.canonicalize_email(entry) |
| 41 for entry in email_list if entry != addr]) |
| 42 |
| 43 |
| 34 def process(addr, message, review, rietveld): | 44 def process(addr, message, review, rietveld): |
| 35 """Handles reviews for chrome/app/policy/policy_templates.json. | 45 """Handles reviews for chrome/app/policy/policy_templates.json. |
| 36 | 46 |
| 37 This looks at the patch to identify additions/modifications to policy | 47 This looks at the patch to identify additions/modifications to policy |
| 38 definitions and posts comments with a checklist intended for the author and | 48 definitions and posts comments with a checklist intended for the author and |
| 39 reviewer to go through in order to catch common mistakes. | 49 reviewer to go through in order to catch common mistakes. |
| 40 """ | 50 """ |
| 41 | 51 |
| 42 if POLICY_TEMPLATES_FILE not in review.latest_patchset.files: | 52 if POLICY_TEMPLATES_FILE not in review.latest_patchset.files: |
| 43 return | 53 return |
| (...skipping 27 matching lines...) Expand all Loading... |
| 71 continue | 81 continue |
| 72 | 82 |
| 73 rietveld.add_inline_comment( | 83 rietveld.add_inline_comment( |
| 74 review.issue_id, review.latest_patchset.patchset, | 84 review.issue_id, review.latest_patchset.patchset, |
| 75 review.latest_patchset.files[POLICY_TEMPLATES_FILE].id, | 85 review.latest_patchset.files[POLICY_TEMPLATES_FILE].id, |
| 76 line, side, template.render(review=review, chunk=chunk)) | 86 line, side, template.render(review=review, chunk=chunk)) |
| 77 | 87 |
| 78 # Finally, post all inline comments. | 88 # Finally, post all inline comments. |
| 79 if len(chunks) > 0: | 89 if len(chunks) > 0: |
| 80 template = JINJA_ENVIRONMENT.get_template(REVIEW_MESSAGE_TEMPLATE) | 90 template = JINJA_ENVIRONMENT.get_template(REVIEW_MESSAGE_TEMPLATE) |
| 81 rietveld.post_comment(review.issue_id, template.render(review=review), True) | 91 rietveld.publish_inline_comments( |
| 92 review.issue_id, template.render(review=review), |
| 93 prepare_address_list(addr, review.issue_data.reviewers), |
| 94 prepare_address_list(addr, review.issue_data.cc)) |
| OLD | NEW |