mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-20 20:09:07 +00:00
Use @git_support in all git_* rules
This commit is contained in:
parent
707d91200e
commit
f6a4902074
@ -3,15 +3,13 @@ from thefuck.rules.git_diff_staged import match, get_new_command
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='git diff'),
|
||||
Command(script='git df'),
|
||||
Command(script='git ds')])
|
||||
@pytest.mark.parametrize('command', [Command(script='git diff')])
|
||||
def test_match(command):
|
||||
assert match(command, None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='git diff --staged'),
|
||||
Command(script='git tag'),
|
||||
Command(script='git branch'),
|
||||
Command(script='git log')])
|
||||
@ -20,8 +18,6 @@ def test_not_match(command):
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command, new_command', [
|
||||
(Command('git diff'), 'git diff --staged'),
|
||||
(Command('git df'), 'git df --staged'),
|
||||
(Command('git ds'), 'git ds --staged')])
|
||||
(Command('git diff'), 'git diff --staged')])
|
||||
def test_get_new_command(command, new_command):
|
||||
assert get_new_command(command, None) == new_command
|
||||
|
@ -3,22 +3,20 @@ from thefuck.rules.git_stash import match, get_new_command
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cherry_pick_error():
|
||||
return ('error: Your local changes would be overwritten by cherry-pick.\n'
|
||||
'hint: Commit your changes or stash them to proceed.\n'
|
||||
'fatal: cherry-pick failed')
|
||||
cherry_pick_error = (
|
||||
'error: Your local changes would be overwritten by cherry-pick.\n'
|
||||
'hint: Commit your changes or stash them to proceed.\n'
|
||||
'fatal: cherry-pick failed')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def rebase_error():
|
||||
return ('Cannot rebase: Your index contains uncommitted changes.\n'
|
||||
'Please commit or stash them.')
|
||||
rebase_error = (
|
||||
'Cannot rebase: Your index contains uncommitted changes.\n'
|
||||
'Please commit or stash them.')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('command', [
|
||||
Command(script='git cherry-pick a1b2c3d', stderr=cherry_pick_error()),
|
||||
Command(script='git rebase -i HEAD~7', stderr=rebase_error())])
|
||||
Command(script='git cherry-pick a1b2c3d', stderr=cherry_pick_error),
|
||||
Command(script='git rebase -i HEAD~7', stderr=rebase_error)])
|
||||
def test_match(command):
|
||||
assert match(command, None)
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
import re
|
||||
from thefuck import shells
|
||||
from thefuck import utils, shells
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def match(command, settings):
|
||||
return ('git' in command.script
|
||||
and 'did not match any file(s) known to git.' in command.stderr
|
||||
and "Did you forget to 'git add'?" in command.stderr)
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def get_new_command(command, settings):
|
||||
missing_file = re.findall(
|
||||
r"error: pathspec '([^']*)' "
|
||||
|
@ -1,10 +1,12 @@
|
||||
from thefuck import shells
|
||||
from thefuck import utils, shells
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def match(command, settings):
|
||||
# catches "git branch list" in place of "git branch"
|
||||
return command.script.split() == 'git branch list'.split()
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def get_new_command(command, settings):
|
||||
return shells.and_('git branch --delete list', 'git branch')
|
||||
|
@ -1,13 +1,15 @@
|
||||
import re
|
||||
from thefuck import shells
|
||||
from thefuck import shells, utils
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def match(command, settings):
|
||||
return ('git' in command.script
|
||||
and 'did not match any file(s) known to git.' in command.stderr
|
||||
and "Did you forget to 'git add'?" not in command.stderr)
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def get_new_command(command, settings):
|
||||
missing_file = re.findall(
|
||||
r"error: pathspec '([^']*)' "
|
||||
|
@ -1,6 +1,13 @@
|
||||
from thefuck import utils
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def match(command, settings):
|
||||
return command.script.startswith('git d')
|
||||
return ('git' in command.script and
|
||||
'diff' in command.script and
|
||||
'--staged' not in command.script)
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def get_new_command(command, settings):
|
||||
return '{} --staged'.format(command.script)
|
||||
|
@ -1,8 +1,8 @@
|
||||
from difflib import get_close_matches
|
||||
import re
|
||||
from thefuck.utils import get_closest
|
||||
from thefuck.utils import get_closest, git_support
|
||||
|
||||
|
||||
@git_support
|
||||
def match(command, settings):
|
||||
return ('git' in command.script
|
||||
and " is not a git command. See 'git --help'." in command.stderr
|
||||
@ -18,6 +18,7 @@ def _get_all_git_matched_commands(stderr):
|
||||
yield line.strip()
|
||||
|
||||
|
||||
@git_support
|
||||
def get_new_command(command, settings):
|
||||
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
|
||||
command.stderr)[0]
|
||||
|
@ -1,12 +1,14 @@
|
||||
from thefuck import shells
|
||||
from thefuck import shells, utils
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def match(command, settings):
|
||||
return ('git' in command.script
|
||||
and 'pull' in command.script
|
||||
and 'set-upstream' in command.stderr)
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def get_new_command(command, settings):
|
||||
line = command.stderr.split('\n')[-3].strip()
|
||||
branch = line.split(' ')[-1]
|
||||
|
@ -1,8 +1,13 @@
|
||||
from thefuck import utils
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def match(command, settings):
|
||||
return ('git' in command.script
|
||||
and 'push' in command.script
|
||||
and 'set-upstream' in command.stderr)
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def get_new_command(command, settings):
|
||||
return command.stderr.split('\n')[-3].strip()
|
||||
|
@ -1,12 +1,14 @@
|
||||
from thefuck import shells
|
||||
from thefuck import shells, utils
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def match(command, settings):
|
||||
# catches "Please commit or stash them" and "Please, commit your changes or
|
||||
# stash them before you can switch branches."
|
||||
return 'git' in command.script and 'or stash them' in command.stderr
|
||||
|
||||
|
||||
@utils.git_support
|
||||
def get_new_command(command, settings):
|
||||
formatme = shells.and_('git stash', '{}')
|
||||
return formatme.format(command.script)
|
||||
|
Loading…
x
Reference in New Issue
Block a user