mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 02:01:13 +00:00
add git-lfs support (#1056)
* add mistyping support for git lfs * add the rule * fix flake8 * flake8 * add to readme * use fixtures and regex * get rid of additional matched strings
This commit is contained in:
parent
6975d30818
commit
f82176802e
@ -214,6 +214,7 @@ following rules are enabled by default:
|
|||||||
* `git_fix_stash` – fixes `git stash` commands (misspelled subcommand and missing `save`);
|
* `git_fix_stash` – fixes `git stash` commands (misspelled subcommand and missing `save`);
|
||||||
* `git_flag_after_filename` – fixes `fatal: bad flag '...' after filename`
|
* `git_flag_after_filename` – fixes `fatal: bad flag '...' after filename`
|
||||||
* `git_help_aliased` – fixes `git help <alias>` commands replacing <alias> with the aliased command;
|
* `git_help_aliased` – fixes `git help <alias>` commands replacing <alias> with the aliased command;
|
||||||
|
* `git_lfs_mistype` – fixes mistyped `git lfs <command>` commands;
|
||||||
* `git_merge` – adds remote to branch names;
|
* `git_merge` – adds remote to branch names;
|
||||||
* `git_merge_unrelated` – adds `--allow-unrelated-histories` when required
|
* `git_merge_unrelated` – adds `--allow-unrelated-histories` when required
|
||||||
* `git_not_command` – fixes wrong git commands like `git brnch`;
|
* `git_not_command` – fixes wrong git commands like `git brnch`;
|
||||||
|
29
tests/rules/test_git_lfs_mistype.py
Normal file
29
tests/rules/test_git_lfs_mistype.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from thefuck.rules.git_lfs_mistype import match, get_new_command
|
||||||
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def mistype_response():
|
||||||
|
return """
|
||||||
|
Error: unknown command "evn" for "git-lfs"
|
||||||
|
|
||||||
|
Did you mean this?
|
||||||
|
env
|
||||||
|
ext
|
||||||
|
|
||||||
|
Run 'git-lfs --help' for usage.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def test_match(mistype_response):
|
||||||
|
assert match(Command('git lfs evn', mistype_response))
|
||||||
|
err_response = 'bash: git: command not found'
|
||||||
|
assert not match(Command('git lfs env', err_response))
|
||||||
|
assert not match(Command('docker lfs env', mistype_response))
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_new_command(mistype_response):
|
||||||
|
assert (get_new_command(Command('git lfs evn', mistype_response))
|
||||||
|
== ['git lfs env', 'git lfs ext'])
|
18
thefuck/rules/git_lfs_mistype.py
Normal file
18
thefuck/rules/git_lfs_mistype.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import re
|
||||||
|
from thefuck.utils import get_all_matched_commands, replace_command
|
||||||
|
from thefuck.specific.git import git_support
|
||||||
|
|
||||||
|
|
||||||
|
@git_support
|
||||||
|
def match(command):
|
||||||
|
'''
|
||||||
|
Match a mistyped command
|
||||||
|
'''
|
||||||
|
return 'lfs' in command.script and 'Did you mean this?' in command.output
|
||||||
|
|
||||||
|
|
||||||
|
@git_support
|
||||||
|
def get_new_command(command):
|
||||||
|
broken_cmd = re.findall(r'Error: unknown command "([^"]*)" for "git-lfs"', command.output)[0]
|
||||||
|
matched = get_all_matched_commands(command.output, ['Did you mean', ' for usage.'])
|
||||||
|
return replace_command(command, broken_cmd, matched)
|
Loading…
x
Reference in New Issue
Block a user