Merge d2c622e4d1 into 62e0767c50
This commit is contained in:
commit
bf630d0442
|
|
@ -245,6 +245,7 @@ following rules are enabled by default:
|
|||
* `git_commit_reset` – offers `git reset HEAD~` after previous commit;
|
||||
* `git_diff_no_index` – adds `--no-index` to previous `git diff` on untracked files;
|
||||
* `git_diff_staged` – adds `--staged` to previous `git diff` with unexpected output;
|
||||
* `git_direct_commit` – adds the files to the staged level, in case that the user tries to commit some changes but has forgotten this step;
|
||||
* `git_fix_stash` – fixes `git stash` commands (misspelled subcommand and missing `save`);
|
||||
* `git_flag_after_filename` – fixes `fatal: bad flag '...' after filename`
|
||||
* `git_help_aliased` – fixes `git help <alias>` commands replacing <alias> with the aliased command;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
import pytest
|
||||
|
||||
from thefuck.rules.git_direct_commit import match, get_new_command
|
||||
from thefuck.types import Command
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"script, output",
|
||||
[('''git commit -m "make an other commit"''', "Changes not staged for commit")]
|
||||
)
|
||||
def test_match(script, output):
|
||||
assert match(Command(script, output))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"script, output",
|
||||
[('''git commit -m "make a commit"''', "")]
|
||||
)
|
||||
def test_not_match(script, output):
|
||||
assert not match(Command(script, output))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"script, output, new_command",
|
||||
[("git commit -m 'make a commit'", "Untracked files", "git add --all && git commit -m 'make a commit'")]
|
||||
)
|
||||
def test_get_new_command(script, output, new_command):
|
||||
assert get_new_command(Command(script, output)) == new_command
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
def match(command):
|
||||
return 'git commit ' in command.script and ('Untracked files' in command.output
|
||||
or '''use "git add"''' in command.output or 'Changes not staged for commit'
|
||||
in command.output)
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
return 'git add --all && ' + command.script
|
||||
|
||||
|
||||
priority = 900
|
||||
Loading…
Reference in New Issue