1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-21 20:38:54 +00:00

Merge pull request #230 from scorphus/git-diff-staged-rule

add(rule): add the new git_diff_staged rule
This commit is contained in:
Vladimir Iakovlev 2015-06-01 08:10:06 +03:00
commit 3c8978784b
3 changed files with 34 additions and 0 deletions

View File

@ -159,6 +159,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
* `java` – removes `.java` extension when running Java programs;
* `git_add` – fix *"Did you forget to 'git add'?"*;
* `git_checkout` – creates the branch before checking-out;
* `git_diff_staged` – adds `--staged` to previous `git diff` with unexpected output;
* `git_no_command` – fixes wrong git commands like `git brnch`;
* `git_pull` – sets upstream before executing previous `git pull`;
* `git_push` – adds `--set-upstream origin $branch` to previous failed `git push`;

View File

@ -0,0 +1,27 @@
import pytest
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')])
def test_match(command):
assert match(command, None)
@pytest.mark.parametrize('command', [
Command(script='git tag'),
Command(script='git branch'),
Command(script='git log')])
def test_not_match(command):
assert not match(command, None)
@pytest.mark.parametrize('command, new_command', [
(Command('git diff'), 'git diff --staged'),
(Command('git df'), 'git df --staged'),
(Command('git ds'), 'git ds --staged')])
def test_get_new_command(command, new_command):
assert get_new_command(command, None) == new_command

View File

@ -0,0 +1,6 @@
def match(command, settings):
return command.script.startswith('git d')
def get_new_command(command, settings):
return '{} --staged'.format(command.script)