Ejemplo n.º 1
0
def get_new_command(command):
    broken_cmd = re.findall(r"Command \"([^']*)\" is not defined",
                            command.stderr)[0]
    new_cmd = re.findall(r'Did you mean this\?[^\n]*\n\s*([^\n]*)',
                         command.stderr)
    if not new_cmd:
        new_cmd = re.findall(r'Did you mean one of these\?[^\n]*\n\s*([^\n]*)',
                             command.stderr)
    return replace_argument(command.script, broken_cmd, new_cmd[0].strip())
Ejemplo n.º 2
0
def get_new_command(command):
    missing_file = re.findall(
        r"error: pathspec '([^']*)' "
        r"did not match any file\(s\) known to git.", command.stderr)[0]
    closest_branch = utils.get_closest(missing_file, get_branches(),
                                       fallback_to_first=False)
    if closest_branch:
        return replace_argument(command.script, missing_file, closest_branch)
    else:
        return shell.and_('git branch {}', '{}').format(
            missing_file, command.script)
Ejemplo n.º 3
0
def get_new_command(command):
    stash_cmd = command.script_parts[2]
    fixed = utils.get_closest(stash_cmd,
                              stash_commands,
                              fallback_to_first=False)

    if fixed is not None:
        return replace_argument(command.script, stash_cmd, fixed)
    else:
        cmd = command.script_parts[:]
        cmd.insert(2, 'save')
        return ' '.join(cmd)
Ejemplo n.º 4
0
def get_new_command(command):
    missing_file = re.findall(
        r"error: pathspec '([^']*)' "
        r"did not match any file\(s\) known to git.", command.stderr)[0]
    closest_branch = utils.get_closest(missing_file,
                                       get_branches(),
                                       fallback_to_first=False)
    if closest_branch:
        return replace_argument(command.script, missing_file, closest_branch)
    else:
        return shell.and_('git branch {}',
                          '{}').format(missing_file, command.script)
Ejemplo n.º 5
0
def get_new_command(command):
    return replace_argument(command.script, 'set-url', 'add')
Ejemplo n.º 6
0
def get_new_command(command):
    npm_commands = _get_available_commands(command.stdout)
    wrong_command = _get_wrong_command(command.script_parts)
    fixed = get_closest(wrong_command, npm_commands)
    return replace_argument(command.script, wrong_command, fixed)
Ejemplo n.º 7
0
def get_new_command(command):
    return shell.and_(replace_argument(command.script, 'push', 'pull'),
                      command.script)
Ejemplo n.º 8
0
def get_new_command(command):
    return replace_argument(command.script, 'set-url', 'add')
Ejemplo n.º 9
0
def test_replace_argument(args, result):
    assert replace_argument(*args) == result
Ejemplo n.º 10
0
def get_new_command(command):
    return replace_argument(command.script, 'diff', 'diff --staged')
Ejemplo n.º 11
0
def get_new_command(command):
    return shell.and_(replace_argument(command.script, 'push', 'pull'),
                      command.script)
Ejemplo n.º 12
0
def get_new_command(command):
    not_exist_formula = re.findall(r'Error: No available formula for ([a-z]+)',
                                   command.stderr)[0]
    exist_formula = _get_similar_formula(not_exist_formula)

    return replace_argument(command.script, not_exist_formula, exist_formula)
Ejemplo n.º 13
0
def get_new_command(command):
    npm_commands = _get_available_commands(command.stdout)
    wrong_command = _get_wrong_command(command.script_parts)
    fixed = get_closest(wrong_command, npm_commands)
    return replace_argument(command.script, wrong_command, fixed)
Ejemplo n.º 14
0
def get_new_command(command):
    broken_cmd = re.findall(r'ERROR: unknown command \"([a-z]+)\"',
                            command.stderr)[0]
    new_cmd = re.findall(r'maybe you meant \"([a-z]+)\"', command.stderr)[0]

    return replace_argument(command.script, broken_cmd, new_cmd)
Ejemplo n.º 15
0
def get_new_command(command):
    return replace_argument(command.script, 'push', 'push --force-with-lease')
Ejemplo n.º 16
0
def get_new_command(command):
    broken = command.script_parts[1]
    fix = re.findall(r'Did you mean `([^`]*)`', command.stderr)[0]

    return replace_argument(command.script, broken, fix)
Ejemplo n.º 17
0
def test_replace_argument(args, result):
    assert replace_argument(*args) == result
Ejemplo n.º 18
0
def get_new_command(command):
    return replace_argument(command.script, '-d', '-D')
Ejemplo n.º 19
0
def get_new_command(command):
    return replace_argument(command.script, 'push', 'push --force-with-lease')
Ejemplo n.º 20
0
def get_new_command(command):
    return replace_argument(command.script, 'pull', 'clone')
Ejemplo n.º 21
0
def get_new_command(command):
    to = command.stderr.split('`')[1]
    return replace_argument(command.script, to[1:], to)