Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@git_support
def match(command):
# catches "git branch list" in place of "git branch"
return (command.script_parts
and command.script_parts[1:] == 'branch list'.split())
@git_support
def get_new_command(command):
line = command.output.split('\n')[-3].strip()
branch = line.split(' ')[-1]
set_upstream = line.replace('', 'origin')\
.replace('', branch)
return shell.and_(set_upstream, command.script)
@git_support
def match(command):
return (
{'rebase', '--continue'}.issubset(command.script_parts) and
'No changes - did you forget to use \'git add\'?' in command.output
)
@git_support
def match(command):
return (" is not a git command. See 'git --help'." in command.output
and ('The most similar command' in command.output
or 'Did you mean' in command.output))
@git_support
def get_new_command(command):
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
command.output)[0]
matched = get_all_matched_commands(command.output, ['The most similar command', 'Did you mean'])
return replace_command(command, broken_cmd, matched)
@git_support
@eager
def get_new_command(command):
branch_name = re.findall(
r"fatal: A branch named '(.+)' already exists.", command.output)[0]
branch_name = branch_name.replace("'", r"\'")
new_command_templates = [['git branch -d {0}', 'git branch {0}'],
['git branch -d {0}', 'git checkout -b {0}'],
['git branch -D {0}', 'git branch {0}'],
['git branch -D {0}', 'git checkout -b {0}'],
['git checkout {0}']]
for new_command_template in new_command_templates:
yield shell.and_(*new_command_template).format(branch_name)
@git_support
def get_new_command(command):
return replace_argument(command.script, 'add', 'add --force')
@git_support
def get_new_command(command):
formatme = shell.and_('git stash', '{}')
return formatme.format(command.script)
@git_support
def match(command):
return ("fatal: A branch named '" in command.output
and "' already exists." in command.output)
@git_support
def get_new_command(command):
command_parts = command.script_parts[:]
index = command_parts.index('rm') + 1
command_parts.insert(index, '--cached')
command_list = [u' '.join(command_parts)]
command_parts[index] = '-f'
command_list.append(u' '.join(command_parts))
return command_list