コード例 #1
0
def list_patch_status(bugzilla_id):
    '''
    List all patches status for a bug
    Last created first
    '''
    patch_status = PatchStatus.query \
        .join(BugResult) \
        .filter_by(bugzilla_id=bugzilla_id) \
        .order_by(PatchStatus.created.desc()) \
        .all()

    return [serialize_patch_status(ps) for ps in patch_status]
コード例 #2
0
def create_patch_status(bugzilla_id):
    '''
    Create or Update a patch status for a bug
    '''
    try:
        bug = BugResult.query.filter_by(bugzilla_id=bugzilla_id).one()
    except NoResultFound:
        logger.warn('Missing bug {}'.format(bugzilla_id))
        abort(404)

    try:
        # Retrieve existing patch status
        ps = PatchStatus.query.filter_by(
            bug_id=bug.id,
            revision=request.json['revision'],
            revision_parent=request.json['revision_parent'],
            branch=request.json['branch'],
        ).one()
    except NoResultFound:
        # Build new patch status
        ps = PatchStatus(bug_id=bug.id)
        ps.revision = request.json['revision']
        ps.revision_parent = request.json['revision_parent']
        ps.branch = request.json['branch']

    # Update data
    ps.group = request.json['group']  # link between graft tests
    ps.status = request.json['status']
    ps.message = request.json['message']

    # Update bug payload to use new patch status
    payload = bug.payload_data
    patches = payload['analysis'].get('patches', {})
    if ps.revision in patches:
        patch = patches[ps.revision]
        if 'merge' not in patch:
            patch['merge'] = {}
        patch['merge'][ps.branch] = ps.status == 'merged'
        payload['analysis']['patches'][ps.revision] = patch

        bug.payload = pickle.dumps(payload, 2)
        db.session.add(bug)

    else:
        logger.warn('Failed to save merge status',
                    rev=ps.revision,
                    branch=ps.branch)  # noqa

    # Commit changes
    db.session.add(ps)
    db.session.commit()

    return serialize_patch_status(ps)
コード例 #3
0
def create_patch_status(bugzilla_id):
    '''
    Create a patch status for a bug
    '''
    try:
        bug = BugResult.query.filter_by(bugzilla_id=bugzilla_id).one()
    except:
        raise Exception('Missing bug {}'.format(bugzilla_id))

    # Build new patch status
    ps = PatchStatus(bug_id=bug.id)
    ps.group = request.json['group']  # link between graft tests
    ps.revision = request.json['revision']
    ps.revision_parent = request.json['revision_parent']
    ps.status = request.json['status']
    ps.branch = request.json['branch']
    ps.message = request.json['message']

    # Update bug payload to use new patch status
    payload = bug.payload_data
    patches = payload['analysis'].get('patches', {})
    if ps.revision in patches:
        patch = patches[ps.revision]
        if 'merge' not in patch:
            patch['merge'] = {}
        patch['merge'][ps.branch] = ps.status == 'merged'
        payload['analysis']['patches'][ps.revision] = patch

        bug.payload = pickle.dumps(payload, 2)
        db.session.add(bug)

    else:
        logger.warn('Failed to save merge status',
                    rev=ps.revision,
                    branch=ps.branch)  # noqa

    # Commit changes
    db.session.add(ps)

    try:
        db.session.commit()
    except IntegrityError as e:
        return {
            'error_title': 'Patch status already exist',
            'error_message': str(e),
        }, 409  # Conflict

    return serialize_patch_status(ps)