def get(self, testcase): """Find similar issues.""" filter_type = request.get('filterType') only_open = filter_type == 'open' issue_tracker = helpers.get_issue_tracker_for_testcase(testcase) items = self.get_issues(issue_tracker, testcase, only_open) response = { 'queryString': ' '.join(issue_tracker_utils.get_search_keywords(testcase)), 'queryUrl': issue_tracker_utils.get_similar_issues_url(issue_tracker, testcase, only_open), 'items': items, } return self.render_json(response)
def update_issue(testcase, issue_id, needs_summary_update): """Associate (or update) an existing issue with the testcase.""" issue_id = helpers.cast(issue_id, int, 'Issue ID (%s) is not a number!' % issue_id) issue_tracker = helpers.get_issue_tracker_for_testcase(testcase) issue = helpers.get_or_exit( lambda: issue_tracker.get_issue(issue_id), 'Issue (id=%d) is not found!' % issue_id, 'Failed to get the issue (id=%s).' % issue_id, Exception) if not issue.is_open: raise helpers.EarlyExitException( ('The issue (%d) is already closed and further updates are not' ' allowed. Please file a new issue instead!') % issue_id, 400) if not testcase.is_crash(): raise helpers.EarlyExitException( 'This is not a crash testcase, so issue update is not applicable.', 400) issue_comment = data_handler.get_issue_description( testcase, helpers.get_user_email()) if needs_summary_update: issue.title = data_handler.get_issue_summary(testcase) policy = issue_tracker_policy.get(issue_tracker.project) properties = policy.get_existing_issue_properties() for label in properties.labels: for result in issue_filer.apply_substitutions( policy, label, testcase): issue.labels.add(result) issue.save(new_comment=issue_comment) testcase.bug_information = str(issue_id) testcase.put() data_handler.update_group_bug(testcase.group_id) helpers.log('Updated issue %sd' % issue_id, helpers.MODIFY_OPERATION)
def update_issue(testcase, issue_id, needs_summary_update): """Associate (or update) an existing issue with the testcase.""" issue_id = helpers.cast(issue_id, int, 'Issue ID (%s) is not a number!' % issue_id) issue_tracker = helpers.get_issue_tracker_for_testcase(testcase) issue = helpers.get_or_exit( lambda: issue_tracker.get_issue(issue_id), 'Issue (id=%d) is not found!' % issue_id, 'Failed to get the issue (id=%s).' % issue_id, Exception) if not issue.is_open: raise helpers.EarlyExitException( ('The issue (%d) is already closed and further updates are not' ' allowed. Please file a new issue instead!') % issue_id, 400) # Create issue parameters. issue_comment = data_handler.get_issue_description( testcase, helpers.get_user_email()) issue_summary = data_handler.get_issue_summary(testcase) # NULL states leads to unhelpful summaries, so do not update in that case. if needs_summary_update and testcase.crash_state != 'NULL': issue.title = issue_summary # Add label on memory tool used. issue_filer.add_memory_tool_label_if_needed(issue, testcase) # Add view restrictions for internal job types. issue_filer.add_view_restrictions_if_needed(issue, testcase) # Don't enforce security severity label on an existing issue. issue.save(new_comment=issue_comment) testcase.bug_information = str(issue_id) testcase.put() data_handler.update_group_bug(testcase.group_id) helpers.log('Updated issue %sd' % issue_id, helpers.MODIFY_OPERATION)
def create_issue(testcase, severity, cc_me): """Create an issue.""" issue_tracker = helpers.get_issue_tracker_for_testcase(testcase) user_email = helpers.get_user_email() if severity is not None: severity = helpers.cast( severity, int, 'Invalid value for security severity (%s).' % severity) additional_ccs = [] if cc_me == 'true': additional_ccs.append(user_email) issue_id = issue_filer.file_issue( testcase, issue_tracker, security_severity=severity, user_email=user_email, additional_ccs=additional_ccs) if not issue_id: raise helpers.EarlyExitException('Unable to create new issue.', 500)