diff --git a/README.md b/README.md index 57ca6234..abbc166e 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,7 @@ following rules are enabled by default: * `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 ` commands replacing with the aliased command; +* `git_log` – replaces `git lock` command with `git log`; * `git_merge` – adds remote to branch names; * `git_merge_unrelated` – adds `--allow-unrelated-histories` when required * `git_not_command` – fixes wrong git commands like `git brnch`; diff --git a/tests/rules/test_git_log.py b/tests/rules/test_git_log.py new file mode 100644 index 00000000..a555aae6 --- /dev/null +++ b/tests/rules/test_git_log.py @@ -0,0 +1,25 @@ +import pytest +from thefuck.rules.git_log import match, get_new_command +from thefuck.types import Command + + +@pytest.mark.parametrize('script, output', [ + ('git lock', 'git: \'lock\' is not a git command.'), + ('git lock --help', 'git: \'lock\' is not a git command.')]) +def test_match(output, script): + assert match(Command(script, output)) + + +@pytest.mark.parametrize('script', [ + 'git branch foo', + 'git checkout feature/test_commit', + 'git push']) +def test_not_match(script): + assert not match(Command(script, '')) + + +@pytest.mark.parametrize('script, output', [ + ('git lock', 'git log'), + ('git lock --help', 'git log --help')]) +def test_get_new_command(script, output): + assert get_new_command(Command(script, '')) == output diff --git a/thefuck/rules/git_log.py b/thefuck/rules/git_log.py new file mode 100644 index 00000000..5288f365 --- /dev/null +++ b/thefuck/rules/git_log.py @@ -0,0 +1,11 @@ +from thefuck.specific.git import git_support + + +@git_support +def match(command): + return 'git: \'lock\' is not a git command.' in command.output + + +@git_support +def get_new_command(command): + return command.script.replace('lock', 'log', 1)