Beispiel #1
0
def get_zippered_state(config: AMTargetBranchConfig, remote: str):
    log.info(
        f'Computing status for [{config.upstream} -> {config.target} <- {config.secondary_upstream}]'
    )
    merges: Optional[List[List[str]]] = []
    merges = compute_zippered_merges(remote=remote,
                                     target=config.target,
                                     left_upstream=config.upstream,
                                     right_upstream=config.secondary_upstream,
                                     common_ancestor=config.common_ancestor,
                                     stop_on_first=True)
    if merges:
        return (EdgeStates.working, EdgeStates.working)

    left_commits: Optional[List[str]] = compute_unmerged_commits(
        remote=remote,
        target_branch=config.target,
        upstream_branch=config.upstream)
    right_commits: Optional[List[str]] = compute_unmerged_commits(
        remote=remote,
        target_branch=config.target,
        upstream_branch=config.secondary_upstream)

    left_state = EdgeStates.waiting if left_commits else EdgeStates.clear
    right_state = EdgeStates.waiting if right_commits else EdgeStates.clear
    return (left_state, right_state)
Beispiel #2
0
def print_zippered_edge_status(config: AMTargetBranchConfig,
                               remote: str,
                               graph=None):
    click.echo(
        click.style(
            f'[{config.upstream} -> {config.target} <- {config.secondary_upstream}]',
            bold=True))
    print(f'- This is a zippered merge branch!')

    merges: Optional[List[List[str]]] = []
    merges = compute_zippered_merges(remote=remote,
                                     target=config.target,
                                     left_upstream=config.upstream,
                                     right_upstream=config.secondary_upstream,
                                     common_ancestor=config.common_ancestor,
                                     stop_on_first=True)

    if graph:
        # FIXME: Don't duplicate compute_unmerged_commits in compute_zippered_edges.
        left_edge, right_edge = compute_zippered_edges(config, remote, merges)
        left_edge.materialize(graph)
        right_edge.materialize(graph)

    if not merges:
        left_commits: Optional[List[str]] = compute_unmerged_commits(
            remote=remote,
            target_branch=config.target,
            upstream_branch=config.upstream)
        right_commits: Optional[List[str]] = compute_unmerged_commits(
            remote=remote,
            target_branch=config.target,
            upstream_branch=config.secondary_upstream)
        if not left_commits and not right_commits:
            print(
                f'- There are no unmerged commits. The {config.target} branch is up to date.'
            )
            return

        def lenOrNone(x):
            return len(x) if x else 0

        print(
            f'- There are {lenOrNone(left_commits)} unmerged commits from {config.upstream}.'
        )
        print(
            f'- There are {lenOrNone(right_commits)} unmerged commits from {config.secondary_upstream}.'
        )
        print(f'- The automerger is waiting for unmerged commits in')
        print(
            f'  {config.upstream} and {config.secondary_upstream} to agree on a merge base'
        )
        print(
            f'  from the {config.common_ancestor} branch before performing a zippered merge.'
        )
        return
    print(
        f'- The automerger will perform at least one zippered merge on the next run.'
    )
Beispiel #3
0
def print_zippered_edge_status(config: AMTargetBranchConfig,
                               remote: str,
                               graph=None):
    click.echo(
        click.style(
            f'[{config.upstream} -> {config.target} <- {config.secondary_upstream}]',
            bold=True))
    print(f'- This is a zippered merge branch!')

    merges: Optional[List[List[str]]] = []
    merges = compute_zippered_merges(remote=remote,
                                     target=config.target,
                                     left_upstream=config.upstream,
                                     right_upstream=config.secondary_upstream,
                                     common_ancestor=config.common_ancestor,
                                     stop_on_first=True)

    if graph:
        # FIXME: Don't duplicate compute_unmerged_commits in compute_zippered_edges.
        left_edge, right_edge = compute_zippered_edges(config, remote, merges)
        left_edge.materialize(graph)
        right_edge.materialize(graph)

    left_commits: Optional[List[str]] = compute_unmerged_commits(
        remote=remote,
        target_branch=config.target,
        upstream_branch=config.upstream)
    right_commits: Optional[List[str]] = compute_unmerged_commits(
        remote=remote,
        target_branch=config.target,
        upstream_branch=config.secondary_upstream)
    if not left_commits and not right_commits:
        print(f'- 0 unmerged commits. {config.target} is up to date.')
        return

    def printUnmergedCommits(commits: Optional[List[str]], branch: str):
        num = len(commits) if commits else 0
        print(f'- {num} unmerged commits from {branch}.')

    printUnmergedCommits(commits=left_commits, branch=config.upstream)
    printUnmergedCommits(commits=right_commits,
                         branch=config.secondary_upstream)
    if merges:
        print(f'- The automerger has found a common merge-base.')
        return
    print(f'- The automerger is waiting for unmerged commits to share')
    print(f'  a merge-base from {config.common_ancestor}')
    print(f'  before merging (i.e., one of the upstreams is behind).')