# Path: gg/builtins/github.py
# @cli.group()
# @click.option(
#     "-u",
#     "--github-url",
#     default=GITHUB_URL,
#     help=f"URL to GitHub instance (default: {GITHUB_URL})",
# )
# @pass_config
# def github(config, github_url):
#     """For setting up a GitHub API token."""
#     config.github_url = github_url
# 
# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):
# 
# Path: gg/state.py
# def load(configfile, branch_name):
#     # like read() but returning specifically the state for the current repo
#     key = f"{get_repo_name()}:{branch_name}"
#     return read(configfile)[key]
# 
# 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/utils.py
# def error_out(msg, raise_abort=True):
#     click.echo(click.style(msg, fg="red"))
#     if raise_abort:
#         raise click.Abort
# 
# def get_default_branch(repo, origin_name):
#     # TODO: Figure out how to do this with GitPython
#     res = subprocess.run(
#         f"git remote show {origin_name}".split(),
#         check=True,
#         capture_output=True,
#         cwd=repo.working_tree_dir,
#     )
#     for line in res.stdout.decode("utf-8").splitlines():
#         if line.strip().startswith("HEAD branch:"):
#             return line.replace("HEAD branch:", "").strip()
# 
#     raise NotImplementedError(f"No remote called {origin_name!r}")
# 
# def info_out(msg):
#     click.echo(msg)
# 
# def is_bugzilla(data):
#     if data.get("bugnumber") and data.get("url"):
#         return "bugzilla" in urlparse(data["url"]).netloc
#     return False
# 
# def is_github(data):
#     if data.get("bugnumber") and data.get("url"):
#         return "github" in urlparse(data["url"]).netloc
#     return False
# 
# def success_out(msg):
#     click.echo(click.style(msg, fg="green"))


import os
import re
import time
import click
import git
from gg.builtins import github
from gg.main import cli, pass_config
from gg.state import load, read, load_config
from gg.utils import (
    error_out,
    get_default_branch,
    info_out,
    is_bugzilla,
    is_github,
    success_out,
)
            if not no_verify:
                info_out(
                    "Commit hook failed ({}, exit code {})".format(
                        exception.command, exception.status
                    )
                )
                if exception.stdout:
                    error_out(exception.stdout)
                elif exception.stderr:
                    error_out(exception.stderr)
                else:
                    error_out("Commit hook failed.")
            else:
                commit = index.commit(msg, skip_hooks=True)

        success_out("Commit created {}".format(commit))

    if not state.get("FORK_NAME"):
        info_out("Can't help you push the commit. Please run: gg config --help")
        return 0

    if push_to_origin:
        try:
            repo.remotes[origin_name]
        except IndexError:
            error_out(f"There is no remote called {origin_name!r}")
    else:
        try:
            repo.remotes[state["FORK_NAME"]]
        except IndexError:

# Path: gg/builtins/github.py
# @cli.group()
# @click.option(
#     "-u",
#     "--github-url",
#     default=GITHUB_URL,
#     help=f"URL to GitHub instance (default: {GITHUB_URL})",
# )
# @pass_config
# def github(config, github_url):
#     """For setting up a GitHub API token."""
#     config.github_url = github_url
# 
# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):
# 
# Path: gg/state.py
# def load(configfile, branch_name):
#     # like read() but returning specifically the state for the current repo
#     key = f"{get_repo_name()}:{branch_name}"
#     return read(configfile)[key]
# 
# 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/utils.py
# def error_out(msg, raise_abort=True):
#     click.echo(click.style(msg, fg="red"))
#     if raise_abort:
#         raise click.Abort
# 
# def get_default_branch(repo, origin_name):
#     # TODO: Figure out how to do this with GitPython
#     res = subprocess.run(
#         f"git remote show {origin_name}".split(),
#         check=True,
#         capture_output=True,
#         cwd=repo.working_tree_dir,
#     )
#     for line in res.stdout.decode("utf-8").splitlines():
#         if line.strip().startswith("HEAD branch:"):
#             return line.replace("HEAD branch:", "").strip()
# 
#     raise NotImplementedError(f"No remote called {origin_name!r}")
# 
# def info_out(msg):
#     click.echo(msg)
# 
# def is_bugzilla(data):
#     if data.get("bugnumber") and data.get("url"):
#         return "bugzilla" in urlparse(data["url"]).netloc
#     return False
# 
# def is_github(data):
#     if data.get("bugnumber") and data.get("url"):
#         return "github" in urlparse(data["url"]).netloc
#     return False
# 
# def success_out(msg):
#     click.echo(click.style(msg, fg="green"))


# Path: gg/builtins/commit/gg_commit.py
import os
import re
import time
import click
import git
from gg.builtins import github
from gg.main import cli, pass_config
from gg.state import load, read, load_config
from gg.utils import (
    error_out,
    get_default_branch,
    info_out,
    is_bugzilla,
    is_github,
    success_out,
)

            if not no_verify:
                info_out(
                    "Commit hook failed ({}, exit code {})".format(
                        exception.command, exception.status
                    )
                )
                if exception.stdout:
                    error_out(exception.stdout)
                elif exception.stderr:
                    error_out(exception.stderr)
                else:
                    error_out("Commit hook failed.")
            else:
                commit = index.commit(msg, skip_hooks=True)

        success_out("Commit created {}".format(commit))

    if not state.get("FORK_NAME"):
        info_out("Can't help you push the commit. Please run: gg config --help")
        return 0

    if push_to_origin:
        try:
            repo.remotes[origin_name]
        except IndexError:
            error_out(f"There is no remote called {origin_name!r}")
    else:
        try:
            repo.remotes[state["FORK_NAME"]]
        except IndexError:

            error_out(f"There is no remote called {state['FORK_NAME']!r}")