# Path: thefuck/specific/git.py
# @decorator
# def git_support(fn, command):
#     """Resolves git aliases and supports testing for both git and hub."""
#     # supports GitHub's `hub` command
#     # which is recommended to be used with `alias git=hub`
#     # but at this point, shell aliases have already been resolved
#     if not is_app(command, 'git', 'hub'):
#         return False
# 
#     # perform git aliases expansion
#     if command.output and 'trace: alias expansion:' in command.output:
#         search = re.search("trace: alias expansion: ([^ ]*) => ([^\n]*)",
#                            command.output)
#         alias = search.group(1)
# 
#         # by default git quotes everything, for example:
#         #     'commit' '--amend'
#         # which is surprising and does not allow to easily test for
#         # eg. 'git commit'
#         expansion = ' '.join(shell.quote(part)
#                              for part in shell.split_command(search.group(2)))
#         new_script = re.sub(r"\b{}\b".format(alias), expansion, command.script)
# 
#         command = command.update(script=new_script)
# 
#     return fn(command)


from thefuck.shells import shell
from thefuck.specific.git import git_support
from thefuck.utils import replace_argument


@git_support
def match(command):
    return (
        ("branch -d" in command.script or "branch -D" in command.script)
        and "error: Cannot delete branch '" in command.output
        and "' checked out at '" in command.output
    )



# Path: thefuck/specific/git.py
# @decorator
# def git_support(fn, command):
#     """Resolves git aliases and supports testing for both git and hub."""
#     # supports GitHub's `hub` command
#     # which is recommended to be used with `alias git=hub`
#     # but at this point, shell aliases have already been resolved
#     if not is_app(command, 'git', 'hub'):
#         return False
# 
#     # perform git aliases expansion
#     if command.output and 'trace: alias expansion:' in command.output:
#         search = re.search("trace: alias expansion: ([^ ]*) => ([^\n]*)",
#                            command.output)
#         alias = search.group(1)
# 
#         # by default git quotes everything, for example:
#         #     'commit' '--amend'
#         # which is surprising and does not allow to easily test for
#         # eg. 'git commit'
#         expansion = ' '.join(shell.quote(part)
#                              for part in shell.split_command(search.group(2)))
#         new_script = re.sub(r"\b{}\b".format(alias), expansion, command.script)
# 
#         command = command.update(script=new_script)
# 
#     return fn(command)


# Path: thefuck/rules/git_branch_delete_checked_out.py
from thefuck.shells import shell
from thefuck.specific.git import git_support
from thefuck.utils import replace_argument



@git_support
def match(command):
    return (
        ("branch -d" in command.script or "branch -D" in command.script)
        and "error: Cannot delete branch '" in command.output
        and "' checked out at '" in command.output
    )



@git_support