Ejemplo n.º 1
0
def get_commit_history(repository, revision, push):
    mozciPush = MozciPush([revision], repository.name)
    parent = mozciPush.parent
    parent_sha = parent.revs[-1]

    parents = Push.objects.filter(repository__name=parent.branch, revision=parent_sha)
    parent_repo = Repository.objects.get(name=parent.branch)
    parent_push = parents[0] if len(parents) else None

    resp = {
        'parentSha': parent_sha,
        'exactMatch': False,
        'parentPushRevision': None,
        'parentRepository': RepositorySerializer(parent_repo).data,
        'id': None,
        'jobCounts': None,
        'revisions': [
            CommitSerializer(commit).data for commit in push.commits.all().order_by('-id')
        ],
        'revisionCount': push.commits.count(),
        'currentPush': PushSerializer(push).data,
    }
    if parent_push:
        resp.update(
            {
                # This will be the revision of the Parent, as long as we could find a Push in
                # Treeherder for it.
                'parentPushRevision': parent_push.revision,
                'id': parent_push.id,
                'jobCounts': parent_push.get_status(),
                'exactMatch': parent_sha == parent_push.revision,
            }
        )
    return resp
Ejemplo n.º 2
0
def get_response_object(parent_sha, revisions, revision_count, push,
                        repository):
    """Build a response object that shows the parent and commit history.

    parent_sha -- The SHA of the parent of the latest commit
    revisions -- The revisions/commits of the current Push
    revision_count -- The count of those revisions (may be different from len(revisions)
        because we only keep so many actual revisions in Treeherder, even if the Push has
        more.
    push -- The Push for the parent.  This might be the actual parent Push, or the closest
        thing we could find.  Could also be the Push for the commit of the `parent_sha`.
    repository -- The repository of the parent.  If we can't find a parent Push, then this
        will be the repository of the current Push.
    """

    resp = {
        'parentSha': parent_sha,
        'exactMatch': False,
        'parentPushRevision': None,
        'parentRepository': RepositorySerializer(repository).data,
        'id': None,
        'jobCounts': None,
        'revisions': revisions,
        'revisionCount': revision_count,
    }
    if push:
        resp.update({
            # This will be the revision of the Parent, as long as we could find a Push in
            # Treeherder for it.
            'parentPushRevision': push.revision,
            'id': push.id,
            'jobCounts': push.get_status(),
            'exactMatch': parent_sha == push.revision,
        })
    return resp
Ejemplo n.º 3
0
def get_response_object(parent_sha, push, repository):
    resp = {
        'parentSha': parent_sha,
        'exactMatch': False,
        'revision': None,
        'repository': RepositorySerializer(repository).data,
        'id': None,
        'jobCounts': None,
    }
    if push:
        resp.update({
            'revision': push.revision,
            'id': push.id,
            'jobCounts': push.get_status(),
            'exactMatch': parent_sha == push.revision,
        })
    return resp