Esempio n. 1
0
def list_labels(service, repo):
    """
    List the labels for the selected repository, default to repo in $PWD
    """
    app = App()
    if repo:
        serv = app.get_service(service, repo=repo)
    else:
        serv = app.guess_service()
    repo_labels = serv.list_labels()
    if not repo_labels:
        print("No labels.")
        return
    print(tabulate([
        (
            label.name,
            label.color,
            label.description
        )
        for label in repo_labels
    ], tablefmt="fancy_grid"))
Esempio n. 2
0
def list_prs(service, repo):
    """
    List pull requests of a selected repository, default to repo in $PWD
    """
    a = App()
    if repo:
        s = a.get_service(service, repo=repo)
    else:
        s = a.guess_service()
    prs = s.list_pull_requests()
    if not prs:
        print("No open pull requests.")
        return
    print(tabulate([
        (
            "#%s" % pr['id'],
            pr['title'],
            "@%s" % pr['author'],
            pr['url']
        )
        for pr in prs
    ], tablefmt="fancy_grid"))
Esempio n. 3
0
def update_labels(source_repo, service, source_service, destination):
    """
    Update labels for the selected repository, default to repo in $PWD
    """
    app = App()
    if source_repo:
        serv = app.get_service(source_service, repo=source_repo)
    else:
        serv = app.guess_service()
    repo_labels = serv.list_labels()
    if not repo_labels:
        print("No labels.")
        return

    for repo_for_copy in destination:
        other_serv = app.get_service(service, repo=repo_for_copy)
        changes = other_serv.update_labels(labels=repo_labels)

        click.echo("{changes} labels of {labels_count} copied to {repo_name}".format(
            changes=changes,
            labels_count=len(repo_labels),
            repo_name=repo_for_copy
        ))