예제 #1
0
def roll(options, debug, info, error):
    to_arg = options.args.index('to')
    path = getcwd()
    git = Git(path)
    repo = Repo(path)

    dest = None
    source = None
    active = repo.active_branch
    settings = options.release_tool_settings

    if to_arg == 0:
        source = active
        dest = options.args[1]

        #update()
    elif to_arg == 1:
        source = options.args[0]
        dest = options.args[2]
    else:
        return

    secret = settings['secrets'][str(dest)]

    if secret:
        info('Special permission is required to roll to this branch.')

    if not secret or has_permission(if_matches=secret):
        debug('rebasing {source} onto {dest}...'.format(
            source=source,
            dest=dest
        ))

        if secret:
            debug(git.rebase(source, dest))
            git.tag('-m', message('Roll from {source} to {dest} with special \
permission by {name} <{email}>.'.format(
                    source=source,
                    dest=dest,
                    name=Actor.author().name,
                    email=Actor.author().email
                ), 'tag'),
                '-s',
                'roll-from-' +
                    source + '-to-' +
                    dest + '-' +
                    datetime.utcnow().isoformat().replace(':', '.'),
                output_stream=stdout)
        else:
            debug(git.rebase(source, dest))

        debug('checking out {source}...'.format(source=source))
        debug(git.checkout(active))

        info('Rolled {source} to {dest}.'.format(source=source, dest=dest))
    else:
        error('You do not have permission to roll to this branch')