Esempio n. 1
0
def apply_cmd(patch_id, series, deps, args):
    """Apply patch.

    Apply a patch locally using the 'git-am' command.
    """
    LOG.info('Applying patch: id=%d, series=%s, deps=%r, args=%s', patch_id,
             series, deps, ' '.join(args))

    patch = api.detail('patches', patch_id)

    if deps and not series:
        series = '*'
    elif not deps:
        series = None

    mbox = api.get(patch['mbox'], {'series': series}).content

    cmd = ['git', 'am']
    if args:
        cmd.extend(args)
    else:
        cmd.append('-3')

    p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
    p.communicate(mbox)
Esempio n. 2
0
def download_cmd(patch_id, output, fmt):
    """Download patch in diff or mbox format.

    Download a patch but do not apply it. ``OUTPUT`` is optional and can be an
    output path or ``-`` to output to ``stdout``. If ``OUTPUT`` is not
    provided, the output path will be automatically chosen.
    """
    LOG.debug('Downloading patch: id=%d, format=%s', patch_id, fmt)

    path = None
    patch = api.detail('patches', patch_id)

    if output:
        if fmt == 'diff':
            content = patch['diff']
        else:
            content = api.get(patch['mbox']).text

        output.write(content)

        if output != sys.stdout:
            path = output.name
    else:
        if fmt == 'diff':
            # TODO(stephenfin): We discard the 'diff' field so we can get the
            # filename and save to the correct file. We should expose this
            # information via the API
            path = api.download(patch['mbox'].replace('mbox', 'raw'))
        else:
            path = api.download(patch['mbox'])

    if path:
        LOG.info('Downloaded patch to %s', path)
Esempio n. 3
0
def download_cmd(bundle_id):
    """Download bundle in mbox format.

    Download a bundle but do not apply it.
    """
    LOG.info('Downloading bundle: id=%d', bundle_id)

    bundle = api.detail('bundles', bundle_id)
    output = api.get(bundle['mbox']).text

    click.echo_via_pager(output)
Esempio n. 4
0
def download_cmd(series_id):
    """Download series in mbox format.

    Download a series but do not apply it.
    """
    LOG.info('Downloading series: id=%d', series_id)

    series = api.detail('series', series_id)
    output = api.get(series['mbox']).text

    click.echo_via_pager(output)
Esempio n. 5
0
def download_cmd(patch_id, fmt):
    """Download a patch diff/mbox.

    Download a patch but do not apply it.
    """
    LOG.info('Downloading patch: id=%d, format=%s', patch_id, fmt)

    patch = api.detail('patches', patch_id)

    if fmt == 'diff':
        output = patch['diff']
    else:
        output = api.get(patch['mbox']).text

    click.echo_via_pager(output)
Esempio n. 6
0
def apply_cmd(bundle_id, args):
    """Apply bundle.

    Apply a bundle locally using the 'git-am' command.
    """
    LOG.info('Applying bundle: id=%d', bundle_id)

    bundle = api.detail('bundles', bundle_id)
    mbox = api.get(bundle['mbox']).text

    cmd = ['git', 'am']
    if args:
        cmd.extend(args)
    else:
        cmd.append('-3')

    p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
    p.communicate(mbox)
Esempio n. 7
0
def download_cmd(bundle_id, output):
    """Download bundle in mbox format.

    Download a bundle but do not apply it. ``OUTPUT`` is optional and can be an
    output path or ``-`` to output to ``stdout``. If ``OUTPUT`` is not
    provided, the output path will be automatically chosen.
    """
    LOG.debug('Downloading bundle: id=%s', bundle_id)

    path = None
    bundle = _get_bundle(bundle_id)

    if output:
        output.write(api.get(bundle['mbox']).text)

        if output != sys.stdout:
            path = output.name
    else:
        path = api.download(bundle['mbox'])

    if path:
        LOG.info('Downloaded bundle to %s', path)
Esempio n. 8
0
def download_cmd(series_id, output):
    """Download series in mbox format.

    Download a series but do not apply it. ``OUTPUT`` is optional and can be an
    output path or ``-`` to output to ``stdout``. If ``OUTPUT`` is not
    provided, the output path will be automatically chosen.
    """
    LOG.debug('Downloading series: id=%d', series_id)

    path = None
    series = api.detail('series', series_id)

    if output:
        output.write(api.get(series['mbox']).text)

        if output != sys.stdout:
            path = output.name
    else:
        path = api.download(series['mbox'])

    if path:
        LOG.info('Downloaded series to %s', path)