Exemple #1
0
def try_to_build(series, working_dir, commit, bot):
    try_rmtree(working_dir)

    check_call(['git', 'clone', '-sn', config.get_git_dir(), working_dir])
    check_call(['cp', config.get_git_dir() + '/config', working_dir + '/.git'])
    check_call(['git', 'checkout', commit], cwd=working_dir)
    check_call(['git', 'tag', 'BUILD_HEAD'], cwd=working_dir)

    steps = []

    s, o = apply.apply_series(series, cwd=working_dir)
    steps.append(('apply', s, o))
    if s != 0:
        return s, steps

    cmds = config.get_buildbot(bot)
    for step, cmd in cmds:
        s, o = call_teed_output(['/bin/sh', '-c', cmd], cwd=working_dir)
        steps.append((step, s, o))
        if s != 0:
            return s, steps

    steps = map(lambda (name, s, o): (name, s, ''), steps)

    return 0, steps
Exemple #2
0
def try_to_build(series, working_dir, commit, bot):
    try_rmtree(working_dir)

    check_call(['git', 'clone', '-sn', config.get_git_dir(), working_dir])
    check_call(['cp', config.get_git_dir() + '/config', working_dir + '/.git'])
    check_call(['git', 'checkout', commit], cwd=working_dir)
    check_call(['git', 'tag', 'BUILD_HEAD'], cwd=working_dir)

    steps = []

    s, o = apply.apply_series(series, cwd=working_dir)
    steps.append(('apply', s, o))
    if s != 0:
        return s, steps

    cmds = config.get_buildbot(bot)
    for step, cmd in cmds:
        s, o = call_teed_output(['/bin/sh', '-c', cmd], cwd=working_dir)
        steps.append((step, s, o))
        if s != 0:
            return s, steps

    steps = map(lambda (name, s, o): (name, s, ''), steps)

    return 0, steps
Exemple #3
0
def apply_pull_request(msg, **kwds):
    pull_request = msg['pull-request']
    uri = pull_request['uri'].encode('ascii', errors='ignore')
    refspec = pull_request['refspec'].encode('ascii', errors='ignore')
    remotes = gitcmd.get_remotes(**kwds)
    sob = None

    if 'signed-off-by' in kwds:
        del kwds['signed-off-by']
        name = check_output(['git', 'config', 'user.name'], **kwds).strip()
        email = check_output(['git', 'config', 'user.email'], **kwds).strip()
        sob = '%s <%s>' % (name, email)

    if 'interactive' in kwds:
        del kwds['interactive']

    if uri not in remotes:
        raise Exception(
            '%s is not setup as a remote, please add a remote manually' %
            pull_request['uri'])

    remote = remotes[uri]

    s, o = call_teed_output(['git', 'fetch', remote], **kwds)
    if s != 0:
        return s, o

    s, o = call_teed_output(
        ['git', 'merge', '--no-ff',
         '%s/%s' % (remote, refspec)], **kwds)
    if s != 0:
        return s, o

    # I am not proud of this but I don't see any other option
    if o.strip() == 'Already up-to-date.':
        return 0, o

    o = check_output(['git', 'log', '-1', '--format=%B', 'HEAD'], **kwds)
    o += '\n'
    o += 'Message-id: %s\n' % msg['message-id']
    if sob:
        o += 'Signed-off-by: %s\n' % sob

    return call_teed_output(['git', 'commit', '--amend', '-m', o], **kwds)
Exemple #4
0
def apply_patch(pathname, **kwds):
    opts = [ '--3way' ]
    if 'signed-off-by' in kwds:
        opts.append('-s')
        del kwds['signed-off-by']
    if 'interactive' in kwds:
        opts.append('-i')
        del kwds['interactive']
    opts.append(pathname)
    return call_teed_output(['git', 'am'] + opts, **kwds)
Exemple #5
0
def apply_patch(pathname, **kwds):
    opts = ['--3way']
    if 'signed-off-by' in kwds:
        opts.append('-s')
        del kwds['signed-off-by']
    if 'interactive' in kwds:
        opts.append('-i')
        del kwds['interactive']
    opts.append(pathname)
    return call_teed_output(['git', 'am'] + opts, **kwds)
Exemple #6
0
def apply_pull_request(msg, **kwds):
    pull_request = msg['pull-request']
    uri = pull_request['uri'].encode('ascii', errors='ignore')
    refspec = pull_request['refspec'].encode('ascii', errors='ignore')
    remotes = gitcmd.get_remotes(**kwds)
    sob = None

    if 'signed-off-by' in kwds:
        del kwds['signed-off-by']
        name = check_output(['git', 'config', 'user.name'], **kwds).strip()
        email = check_output(['git', 'config', 'user.email'], **kwds).strip()
        sob = '%s <%s>' % (name, email)

    if 'interactive' in kwds:
        del kwds['interactive']

    if uri not in remotes:
        raise Exception('%s is not setup as a remote, please add a remote manually' % pull_request['uri'])

    remote = remotes[uri]

    s, o = call_teed_output(['git', 'fetch', remote], **kwds)
    if s != 0:
        return s, o

    s, o = call_teed_output(['git', 'merge', '--no-ff', '%s/%s' % (remote, refspec)], **kwds)
    if s != 0:
        return s, o

    # I am not proud of this but I don't see any other option
    if o.strip() == 'Already up-to-date.':
        return 0, o

    o = check_output(['git', 'log', '-1', '--format=%B', 'HEAD'], **kwds)
    o += '\n'
    o += 'Message-id: %s\n' % msg['message-id']
    if sob:
        o += 'Signed-off-by: %s\n' % sob

    return call_teed_output(['git', 'commit', '--amend', '-m', o], **kwds)