def good_bug_comment(repo_dir, bug_id, bug): values = bug['flags_to_set'] comment = generate_good_bug_msg(bug) try: bzapi.update_bug(bug_id, comment=comment, values=values) except Exception, e: raise FailedToComment({ 'exception': e, 'traceback': traceback.format_exc() })
def ugly_bug_comment(repo_dir, bug_id, bug): values = bug['flags_to_set'] bug_data = bzapi.fetch_complete_bug(bug_id, cache_ok=True) flags = make_needinfo(bug_data) comment = generate_ugly_bug_msg(bug) try: bzapi.update_bug(bug_id, comment=comment, values=values, flags=flags) except Exception, e: raise FailedToComment({ 'exception': e, 'traceback': traceback.format_exc() })
def bad_bug_comment(repo_dir, bug_id, bug): # Short circuit for when we don't need to make a comment bug_data = bzapi.fetch_complete_bug(bug_id, cache_ok=True) for c in [x['text'] for x in bug_data['comments']]: if c and 'git cherry-pick' in c: return # If there is an assignee, try to needinfo them! flags = make_needinfo(bug_data) comment = generate_bad_bug_msg(repo_dir, bug) try: bzapi.update_bug(bug_id, comment=comment, values={}, flags=flags) except Exception, e: raise FailedToComment({ 'exception': e, 'traceback': traceback.format_exc() })
def comment(repo_dir, branch_to, commit_range, dry_run=False): all_commits = git.log(repo_dir, commit_range, pretty="%H").strip().split("\n") comments = {} commits_without_bugs = [] assert branch_to in git.branches(repo_dir), "branch parameter must be a branch" i = 0 for commit in all_commits: i += 1 print "bug %d of %d" % (i, len(all_commits)) bug_ids = guess_bug_id(repo_dir, commit) if bug_ids is None or len(bug_ids) == 0: commits_without_bugs.append(commit) else: for bug_id in bug_ids: if not bug_id in comments.keys(): comments[bug_id] = [] comments[bug_id].append(commit) failed_bugs = [] for bug_id in comments.keys(): comment = [] flags = branch_logic.flags_to_set([branch_to]) for commit in comments[bug_id]: comment.append("v1.1.0hd: %s" % commit) comment = "\n".join(comment) print "Commenting on bug %s with:\ntext: %s\nflags: %s" % (bug_id, comment, flags) if not dry_run: try: bzapi.update_bug(bug_id, comment=comment, values=flags) except: failed_bugs.append(bug_id) print "The following commits do not have a bug associated with them:\n%s" % commits_without_bugs print "Failed to comment on the following bugs:\n%s" % failed_bugs