Exemple #1
0
def _GetCommitInfoForAlert(alert):
    repository_url = None
    repositories = namespaced_stored_object.Get('repositories')
    test_path = utils.TestPath(alert.test)
    if test_path.startswith('ChromiumPerf'):
        repository_url = repositories['chromium']['repository_url']
    elif test_path.startswith('ClankInternal'):
        repository_url = repositories['clank']['repository_url']
    if not repository_url:
        # Can't get committer info from this repository.
        return None

    rev = str(auto_bisect.GetRevisionForBisect(alert.end_revision, alert.test))
    # TODO(sullivan, dtu): merge this with similar pinoint code.
    if (re.match(r'^[0-9]{5,7}$', rev)
            and repository_url == repositories['chromium']['repository_url']):
        # This is a commit position, need the git hash.
        result = crrev_service.GetNumbering(
            number=rev,
            numbering_identifier='refs/heads/master',
            numbering_type='COMMIT_POSITION',
            project='chromium',
            repo='chromium/src')
        rev = result['git_sha']
    if not re.match(r'[a-fA-F0-9]{40}$', rev):
        # This still isn't a git hash; can't assign bug.
        return None

    return gitiles_service.CommitInfo(repository_url, rev)
Exemple #2
0
def _AssignBugToCLAuthor(bug_id, alert, service):
    """Assigns the bug to the author of the given revision."""
    repository_url = None
    repositories = namespaced_stored_object.Get('repositories')
    test_path = utils.TestPath(alert.test)
    if test_path.startswith('ChromiumPerf'):
        repository_url = repositories['chromium']['repository_url']
    elif test_path.startswith('ClankInternal'):
        repository_url = repositories['clank']['repository_url']
    if not repository_url:
        # Can't get committer info from this repository.
        return

    rev = str(auto_bisect.GetRevisionForBisect(alert.end_revision, alert.test))
    # TODO(sullivan, dtu): merge this with similar pinoint code.
    if (re.match(r'^[0-9]{5,7}$', rev)
            and repository_url == repositories['chromium']['repository_url']):
        # This is a commit position, need the git hash.
        result = crrev_service.GetNumbering(
            number=rev,
            numbering_identifier='refs/heads/master',
            numbering_type='COMMIT_POSITION',
            project='chromium',
            repo='chromium/src')
        rev = result['git_sha']
    if not re.match(r'[a-fA-F0-9]{40}$', rev):
        # This still isn't a git hash; can't assign bug.
        return

    commit_info = gitiles_service.CommitInfo(repository_url, rev)
    author = commit_info['author']['email']
    message = commit_info['message']
    sheriff = utils.GetSheriffForAutorollCommit(author, message)
    if sheriff:
        service.AddBugComment(
            bug_id,
            ('Assigning to sheriff %s because this autoroll is '
             'the only CL in range:\n%s') % (sheriff, message),
            status='Assigned',
            owner=sheriff)
    else:
        service.AddBugComment(
            bug_id,
            'Assigning to %s because this is the only CL in range:\n%s' %
            (author, message),
            status='Assigned',
            owner=author)