# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):
# 
# Path: gg/utils.py
# def error_out(msg, raise_abort=True):
#     click.echo(click.style(msg, fg="red"))
#     if raise_abort:
#         raise click.Abort
# 
# def info_out(msg):
#     click.echo(msg)
# 
# def success_out(msg):
#     click.echo(click.style(msg, fg="green"))
# 
# def warning_out(msg):
#     click.echo(click.style(msg, fg="yellow"))


import datetime
import click
import git
from gg.main import cli, pass_config
from gg.utils import error_out, info_out, success_out, warning_out
@click.option(
    "-n",
    "--cutoff",
    default=DEFAULT_CUTOFF,
    help="Max. number of branches to show",
    show_default=True,
)
@click.argument("searchstring", default="")
@pass_config
def branches(config, yes=False, searchstring="", cutoff=DEFAULT_CUTOFF):
    """List all branches. And if exactly 1 found, offer to check it out."""
    repo = config.repo

    try:
        branches_ = list(find(repo, searchstring))
    except InvalidRemoteName as exception:
        remote_search_name = searchstring.split(":")[0]
        if remote_search_name in [x.name for x in repo.remotes]:
            error_out(f"Invalid remote name {exception!r}")

        (repo_name,) = [
            x.url.split("/")[-1].split(".git")[0]
            for x in repo.remotes
            if x.name == "origin"
        ]
        # Add it and start again
        remote_url = f"https://github.com/{remote_search_name}/{repo_name}.git"
        if not click.confirm(
            f"Add remote {remote_search_name!r} ({remote_url})", default=True
        ):

# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):
# 
# Path: gg/utils.py
# def error_out(msg, raise_abort=True):
#     click.echo(click.style(msg, fg="red"))
#     if raise_abort:
#         raise click.Abort
# 
# def info_out(msg):
#     click.echo(msg)
# 
# def success_out(msg):
#     click.echo(click.style(msg, fg="green"))
# 
# def warning_out(msg):
#     click.echo(click.style(msg, fg="yellow"))


# Path: gg/builtins/branches/gg_branches.py
import datetime
import click
import git
from gg.main import cli, pass_config
from gg.utils import error_out, info_out, success_out, warning_out

@click.option(
    "-n",
    "--cutoff",
    default=DEFAULT_CUTOFF,
    help="Max. number of branches to show",
    show_default=True,
)
@click.argument("searchstring", default="")
@pass_config
def branches(config, yes=False, searchstring="", cutoff=DEFAULT_CUTOFF):
    """List all branches. And if exactly 1 found, offer to check it out."""
    repo = config.repo

    try:
        branches_ = list(find(repo, searchstring))
    except InvalidRemoteName as exception:
        remote_search_name = searchstring.split(":")[0]
        if remote_search_name in [x.name for x in repo.remotes]:
            error_out(f"Invalid remote name {exception!r}")

        (repo_name,) = [
            x.url.split("/")[-1].split(".git")[0]
            for x in repo.remotes
            if x.name == "origin"
        ]
        # Add it and start again
        remote_url = f"https://github.com/{remote_search_name}/{repo_name}.git"
        if not click.confirm(
            f"Add remote {remote_search_name!r} ({remote_url})", default=True
        ):

            error_out("Unable to find or create remote")