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

Side by Side Diff: appengine/findit/waterfall/post_comment_to_bug_pipeline.py

Issue 2438673004: [Findit] Post analysis results of flakes to bug filed by chromium-try-flakes. (Closed)
Patch Set: Add a config flag to enable/disable updating monorail bug. Created 4 years, 1 month 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
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6
7 from issue_tracker import IssueTrackerAPI
8
9 from common.pipeline_wrapper import BasePipeline
10
11
12 def _GetIssue(bug_id, issue_tracker):
13 """Returns the issue of the given bug.
14
15 Traverse if the bug was merged into another."""
16 issue = issue_tracker.getIssue(bug_id)
17 while issue and issue.merged_into:
18 issue = issue_tracker.getIssue(issue.merged_into)
19 return issue
20
21
22 class PostCommentToBugPipeline(BasePipeline):
23
24 # Arguments number differs from overridden method - pylint: disable=W0221
25 def run(self, bug_id, comment, labels, project_name='chromium'):
26 """Posts a comment and adds labels to the bug.
27
28 Args:
29 bug_id (int): The bug id to update.
30 comment (str): The comment to post.
31 labels (list): A list labels to add.
32 project_name (str): The project name for the bug. Default to 'chromium'.
33 """
34 assert bug_id, 'Invalid bug id: %s' % bug_id
35
36 issue_tracker = IssueTrackerAPI(project_name)
37 issue = _GetIssue(bug_id, issue_tracker)
38 if not issue:
39 logging.warn('Bug %s/%s or the merged-into one seems deleted!',
40 project_name, bug_id)
41 return
42
43 for label in labels:
44 issue.labels.append(label)
45
46 issue_tracker.update(issue, comment, send_email=True)
47 logging.info('Bug %s/%s was updated.', project_name, bug_id)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698