Beispiel #1
0
async def perform_merge_actions(config, task, actions, repo_path):
    """Perform merge day related actions.

    This has different behaviour to other treescript actions:
    * Reporting on outgoing changesets has less meaning
    * Logging outgoing changesets can easily break with the volume and content of the diffs
    * We need to do more than just |hg push -r .| since we have two branches to update

    Args:
        config (dict): the running config
        task (dict): the running task
        actions (list): the actions to perform
        repo_path (str): the source directory to use.
    """
    log.info("Starting merge day operations")
    push_activity = await do_merge(config, task, repo_path)

    if should_push(task, actions) and push_activity:
        log.info("%d branches to push", len(push_activity))
        for target_repo, revision in push_activity:
            log.info("pushing %s to %s", revision, target_repo)
            await push(config,
                       task,
                       repo_path,
                       target_repo=target_repo,
                       revision=revision)
Beispiel #2
0
async def do_actions(config, task, actions, repo_path):
    """Perform the set of actions that treescript can perform.

    The actions happen in order, tagging, ver bump, then push

    Args:
        config (dict): the running config
        task (dict): the running task
        actions (list): the actions to perform
        repo_path (str): the source directory to use.
    """
    await checkout_repo(config, task, repo_path)

    # Split the action selection up due to complexity in do_actions
    # caused by different push behaviour, and action return values.
    if "merge_day" in actions:
        await perform_merge_actions(config, task, actions, repo_path)
        return

    num_changes = 0
    if "tag" in actions:
        num_changes += await do_tagging(config, task, repo_path)
    if "version_bump" in actions:
        num_changes += await bump_version(config, task, repo_path)
    if "l10n_bump" in actions:
        num_changes += await l10n_bump(config, task, repo_path)

    num_outgoing = await log_outgoing(config, task, repo_path)
    if num_outgoing != num_changes:
        raise TreeScriptError(
            "Outgoing changesets don't match number of expected changesets!"
            " {} vs {}".format(num_outgoing, num_changes))
    if should_push(task, actions):
        if num_changes:
            await push(config,
                       task,
                       repo_path,
                       target_repo=get_source_repo(task))
        else:
            log.info("No changes; skipping push.")
    await strip_outgoing(config, task, repo_path)
async def do_actions(config, task, actions, repo_path):
    """Perform the set of actions that treescript can perform.

    The actions happen in order, tagging, ver bump, then push

    Args:
        config (dict): the running config
        task (dict): the running task
        actions (list): the actions to perform
        repo_path (str): the source directory to use.
    """
    source_repo = get_source_repo(task)
    # mercurial had been the only default choice until git was supported, default to it.
    repo_type = "git" if is_github_url(source_repo) else "hg"
    vcs = get_vcs_module(repo_type)
    await vcs.checkout_repo(config, task, repo_path)

    # Split the action selection up due to complexity in do_actions
    # caused by different push behaviour, and action return values.
    if "merge_day" in actions:
        await perform_merge_actions(config, task, actions, repo_path, repo_type)
        return

    num_changes = 0
    if "tag" in actions:
        num_changes += await vcs.do_tagging(config, task, repo_path)
    if "version_bump" in actions:
        num_changes += await bump_version(config, task, repo_path, repo_type)
    if "l10n_bump" in actions:
        num_changes += await l10n_bump(config, task, repo_path, repo_type)

    num_outgoing = await vcs.log_outgoing(config, task, repo_path)
    if num_outgoing != num_changes:
        raise TreeScriptError("Outgoing changesets don't match number of expected changesets!" " {} vs {}".format(num_outgoing, num_changes))
    if should_push(task, actions):
        if num_changes:
            await vcs.push(config, task, repo_path, target_repo=get_source_repo(task))
        else:
            log.info("No changes; skipping push.")
    await vcs.strip_outgoing(config, task, repo_path)
def test_should_push_false(task):
    actions = ttask.task_action_types(SCRIPT_CONFIG, task)
    assert False is ttask.should_push(task, actions)