# 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"))
# 
# Path: gg/state.py
# def read(configfile):
#     with open(configfile, "r") as f:
#         return json.load(f)
# 
# def load_config(configfile, key):
#     # like read() but returning specifically the state for the current repo
#     key = f"{get_repo_name()}:_config:{key}"
#     return read(configfile)[key]
# 
# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):


import git
import click
from gg.utils import error_out, info_out, success_out
from gg.state import read, load_config
from gg.main import cli, pass_config
    # for enum_name in [
    #     "DELETED",
    #     "ERROR",
    #     "FAST_FORWARD",
    #     "NEW_HEAD",
    #     "NEW_TAG",
    #     "NO_MATCH",
    #     "REMOTE_FAILURE",
    # ]:
    #     print(
    #         f"{enum_name}?:", pushed.flags & getattr(git.remote.PushInfo, enum_name)
    #     )

    if pushed.flags & git.remote.PushInfo.FORCED_UPDATE:
        success_out(f"Successfully force pushed to {destination}")
    elif (
        pushed.flags & git.remote.PushInfo.REJECTED
        or pushed.flags & git.remote.PushInfo.REMOTE_REJECTED
    ):
        error_out('The push was rejected ("{}")'.format(pushed.summary), False)

        try_force_push = input("Try to force push? [Y/n] ").lower().strip()
        if try_force_push not in ("no", "n"):
            (pushed,) = destination.push(force=True)
            info_out(pushed.summary)
        else:
            return 0
    elif pushed.flags & git.remote.PushInfo.UP_TO_DATE:
        info_out(f"{destination} already up-to-date")
    else:

# 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"))
# 
# Path: gg/state.py
# def read(configfile):
#     with open(configfile, "r") as f:
#         return json.load(f)
# 
# def load_config(configfile, key):
#     # like read() but returning specifically the state for the current repo
#     key = f"{get_repo_name()}:_config:{key}"
#     return read(configfile)[key]
# 
# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):


# Path: gg/builtins/push/gg_push.py
import git
import click
from gg.utils import error_out, info_out, success_out
from gg.state import read, load_config
from gg.main import cli, pass_config

    # for enum_name in [
    #     "DELETED",
    #     "ERROR",
    #     "FAST_FORWARD",
    #     "NEW_HEAD",
    #     "NEW_TAG",
    #     "NO_MATCH",
    #     "REMOTE_FAILURE",
    # ]:
    #     print(
    #         f"{enum_name}?:", pushed.flags & getattr(git.remote.PushInfo, enum_name)
    #     )

    if pushed.flags & git.remote.PushInfo.FORCED_UPDATE:
        success_out(f"Successfully force pushed to {destination}")
    elif (
        pushed.flags & git.remote.PushInfo.REJECTED
        or pushed.flags & git.remote.PushInfo.REMOTE_REJECTED
    ):
        error_out('The push was rejected ("{}")'.format(pushed.summary), False)

        try_force_push = input("Try to force push? [Y/n] ").lower().strip()
        if try_force_push not in ("no", "n"):
            (pushed,) = destination.push(force=True)
            info_out(pushed.summary)
        else:
            return 0
    elif pushed.flags & git.remote.PushInfo.UP_TO_DATE:
        info_out(f"{destination} already up-to-date")
    else:

        success_out(f"Successfully pushed to {destination}")