def fork(service, repo): """ Fork selected repository """ a = App() s = a.get_service(service) s.fork(repo)
def create_pr(target_remote, target_branch): """ Fork selected repository """ a = App() s = a.guess_service(remote=target_remote) pr_url = s.create_pull_request(target_remote, target_branch, a.get_current_branch()) print(pr_url)
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"))
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"))
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.number, pr.title, "@%s" % pr.user.login, pr.html_url) for pr in prs], tablefmt="fancy_grid"))
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))
def list_branches(): """ List git branches in current git repository """ a = App() print(tabulate(a.list_branches(), tablefmt="fancy_grid"))