# 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,
)
        push_to_origin = False

    try:
        fixes_message = load_config(config.configfile, "fixes_message")
    except KeyError:
        fixes_message = True

    try:
        data = load(config.configfile, active_branch.name)
    except KeyError:
        error_out(
            "You're in a branch that was not created with gg.\n"
            "No branch information available."
        )

    print("Commit message: (type a new one if you want to override)")
    msg = data["description"]
    if data.get("bugnumber"):
        if is_bugzilla(data):
            msg = "bug {} - {}".format(data["bugnumber"], data["description"])
            msg = input('"{}" '.format(msg)).strip() or msg
        elif is_github(data):
            msg = input('"{}" '.format(msg)).strip() or msg
            if fixes_message:
                msg += "\n\nPart of #{}".format(data["bugnumber"])

    if data["bugnumber"] and fixes_message:
        question = 'Add the "fixes" mention? [N/y] '
        fixes = input(question).lower().strip()
        if fixes in ("y", "yes") or yes:

# 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,
)

        push_to_origin = False

    try:
        fixes_message = load_config(config.configfile, "fixes_message")
    except KeyError:
        fixes_message = True

    try:
        data = load(config.configfile, active_branch.name)
    except KeyError:
        error_out(
            "You're in a branch that was not created with gg.\n"
            "No branch information available."
        )

    print("Commit message: (type a new one if you want to override)")
    msg = data["description"]
    if data.get("bugnumber"):
        if is_bugzilla(data):
            msg = "bug {} - {}".format(data["bugnumber"], data["description"])
            msg = input('"{}" '.format(msg)).strip() or msg
        elif is_github(data):
            msg = input('"{}" '.format(msg)).strip() or msg
            if fixes_message:
                msg += "\n\nPart of #{}".format(data["bugnumber"])

    if data["bugnumber"] and fixes_message:
        question = 'Add the "fixes" mention? [N/y] '
        fixes = input(question).lower().strip()
        if fixes in ("y", "yes") or yes:

            if is_bugzilla(data):