Ejemplo n.º 1
0
def get_managed_branches(repo, repo_desc, naming, branch_link_callable=None):
    branch_to_hash = _get_branch_to_hash(repo)
    branch_pairs = abdt_naming.get_branch_pairs(branch_to_hash.keys(), naming)

    managed_branches = []
    lander = abdt_lander.squash

    for b in branch_pairs:
        branch_url = None
        review_branch = b.review
        tracker_branch = b.tracker
        assert review_branch is not None or tracker_branch is not None

        review_hash = None
        tracker_hash = None

        if review_branch is not None:
            review_hash = branch_to_hash[review_branch.branch]
            if branch_link_callable:
                branch_url = branch_link_callable(review_branch.branch)

        if tracker_branch is not None:
            tracker_hash = branch_to_hash[tracker_branch.branch]

        managed_branches.append(
            abdt_branch.Branch(repo, review_branch, review_hash,
                               tracker_branch, tracker_hash, lander, repo_desc,
                               branch_url))

    return managed_branches
Ejemplo n.º 2
0
def process(args):
    repo = phlsys_git.Repo('.')

    #
    # First, gather all the data
    #

    # XXX: only supports 'origin' remote at present
    remote = 'origin'

    hash_ref_pairs = phlgit_showref.hash_ref_pairs(repo)
    remote_branch_to_hash = _remote_branches_as_short_local(
        hash_ref_pairs, remote)
    # local_branch_to_hash = _short_local_branches(hash_ref_pairs)

    branch_naming = abdt_compositenaming.Naming(
        abdt_classicnaming.Naming(),
        abdt_rbranchnaming.Naming())

    branch_pairs = abdt_naming.get_branch_pairs(
        remote_branch_to_hash.keys(), branch_naming)

    managed_review_branches = _get_managed_review_branches(
        remote_branch_to_hash, branch_pairs)

    #
    # Finally, decide how to display it
    #

    if args.format_json:
        print(json.dumps(managed_review_branches, sort_keys=True, indent=2))
    elif args.format_python:
        pprint.pprint(managed_review_branches)
    elif args.format_string:
        for branch in managed_review_branches:
            print(args.format_string.format(**branch))
    else:  # args.format_summary
        if managed_review_branches:
            print("{:6} {:14} {}".format("ID", "status", "tracked name"))
            for branch in managed_review_branches:
                print("{review_id:6} {status:14} {tracked_name}".format(
                    **branch))
Ejemplo n.º 3
0
def process(args):
    repo = phlsys_git.Repo('.')

    #
    # First, gather all the data
    #

    # XXX: only supports 'origin' remote at present
    remote = 'origin'

    hash_ref_pairs = phlgit_showref.hash_ref_pairs(repo)
    remote_branch_to_hash = _remote_branches_as_short_local(
        hash_ref_pairs, remote)
    # local_branch_to_hash = _short_local_branches(hash_ref_pairs)

    branch_naming = abdt_compositenaming.Naming(abdt_classicnaming.Naming(),
                                                abdt_rbranchnaming.Naming())

    branch_pairs = abdt_naming.get_branch_pairs(remote_branch_to_hash.keys(),
                                                branch_naming)

    managed_review_branches = _get_managed_review_branches(
        remote_branch_to_hash, branch_pairs)

    #
    # Finally, decide how to display it
    #

    if args.format_json:
        print(json.dumps(managed_review_branches, sort_keys=True, indent=2))
    elif args.format_python:
        pprint.pprint(managed_review_branches)
    elif args.format_string:
        for branch in managed_review_branches:
            print(args.format_string.format(**branch))
    else:  # args.format_summary
        if managed_review_branches:
            print("{:6} {:14} {}".format("ID", "status", "tracked name"))
            for branch in managed_review_branches:
                print("{review_id:6} {status:14} {tracked_name}".format(
                    **branch))
Ejemplo n.º 4
0
def get_managed_branches(repo, repo_desc, naming, branch_link_callable=None):
    branch_to_hash = _get_branch_to_hash(repo)
    branch_pairs = abdt_naming.get_branch_pairs(branch_to_hash.keys(), naming)

    managed_branches = []
    lander = abdt_lander.squash

    for b in branch_pairs:
        branch_url = None
        review_branch = b.review
        tracker_branch = b.tracker
        assert review_branch is not None or tracker_branch is not None

        review_hash = None
        tracker_hash = None

        if review_branch is not None:
            review_hash = branch_to_hash[review_branch.branch]
            if branch_link_callable:
                branch_url = branch_link_callable(review_branch.branch)

        if tracker_branch is not None:
            tracker_hash = branch_to_hash[tracker_branch.branch]

        managed_branches.append(
            abdt_branch.Branch(
                repo,
                review_branch,
                review_hash,
                tracker_branch,
                tracker_hash,
                lander,
                repo_desc,
                branch_url))

    return managed_branches