コード例 #1
0
def create_branch(args):
    """
    Takes a single branch name and (if necessary) creates a new branch. Then,
    populates the ``build/<branch>`` directory for the new branch using either
    the parent branch or ``master``. Safe to run multiple times (after a rebase)
    to update the build cache from master.

    Also calls :method:`~giza.operations.build_env.fix_build_environment()` to
    tweak the new build output to update hashes and on-disk copies of the
    environment to prevent unnecessary full-rebuilds from sphinx.
    """

    conf = fetch_config(args)

    g = GitRepo(conf.paths.projectroot)

    branch = conf.runstate.git_branch
    base_branch = g.current_branch()

    if base_branch == branch:
        base_branch = 'master'
        logger.warning(
            'seeding build data for branch "{0}" from "master"'.format(branch))

    branch_builddir = os.path.join(conf.paths.projectroot, conf.paths.output,
                                   branch)

    base_builddir = os.path.join(conf.paths.projectroot, conf.paths.output,
                                 base_branch)

    if g.branch_exists(branch):
        logger.info('checking out branch "{0}"'.format(branch))
    else:
        logger.info(
            'creating and checking out a branch named "{0}"'.format(branch))

    g.checkout_branch(branch)

    cmd = "rsync -r --times --checksum {0}/ {1}".format(
        base_builddir, branch_builddir)
    logger.info('seeding build directory for "{0}" from "{1}"'.format(
        branch, base_branch))
    command(cmd)
    logger.info('branch creation complete.')

    # get a new config here for the new branch
    conf = fetch_config(args)
    builders = get_existing_builders(conf)
    app = BuildApp(conf)
    app.pool = 'process'

    fix_build_env_tasks(builders, conf, app)

    app.run()
コード例 #2
0
def setup_branches(args):
    conf = fetch_config(args)

    g = GitRepo(c.paths.projectroot)

    if 'upstream' in g.remotes():
        remote = 'upstream'
    else:
        remote = 'origin'

    for pbranch in conf.git.branches.published:
        if g.branch_exists(pbranch):
            continue
        else:
            tracking_branch = '/'.join([remote, pbranch])
            g.create_branch(pbranch, tracking=tracking_branch)
            logger.info('created branch "{0}" tracking "{1}"'.format(
                pbranch, tracking_branch))