diff --git a/README.md b/README.md index 360b1981..31dc1527 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,7 @@ using the matched rule and runs it. Rules enabled by default are as follows: * `git_push_pull` – runs `git pull` when `push` was rejected; * `git_push_without_commits` – Creates an initial commit if you forget and only `git add .`, when setting up a new project; * `git_rebase_no_changes` – runs `git rebase --skip` instead of `git rebase --continue` when there are no changes; +* `git_remote_delete` – replaces `git remote delete remote_name` with `git remote remove remote_name` * `git_rm_local_modifications` – adds `-f` or `--cached` when you try to `rm` a locally modified file; * `git_rm_recursive` – adds `-r` when you try to `rm` a directory; * `git_rm_staged` – adds `-f` or `--cached` when you try to `rm` a file with staged changes diff --git a/tests/rules/test_git_remote_delete.py b/tests/rules/test_git_remote_delete.py new file mode 100644 index 00000000..660f0c8b --- /dev/null +++ b/tests/rules/test_git_remote_delete.py @@ -0,0 +1,21 @@ +import pytest +from thefuck.rules.git_remote_delete import get_new_command, match +from thefuck.types import Command + + +def test_match(): + assert match(Command('git remote delete foo', '')) + + +@pytest.mark.parametrize('command', [ + Command('git remote remove foo', ''), + Command('git remote add foo', ''), + Command('git commit', '') +]) +def test_not_match(command): + assert not match(command) + + +def test_get_new_command(): + new_command = get_new_command(Command('git remote delete foo', '')) + assert new_command == 'git remote remove foo' diff --git a/thefuck/rules/git_remote_delete.py b/thefuck/rules/git_remote_delete.py new file mode 100644 index 00000000..4cde87b3 --- /dev/null +++ b/thefuck/rules/git_remote_delete.py @@ -0,0 +1,15 @@ +from thefuck.utils import replace_argument +from thefuck.specific.git import git_support + + +@git_support +def match(command): + return "git remote delete" in command.script + + +@git_support +def get_new_command(command): + return replace_argument(command.script, "delete", "remove") + + +enabled_by_default = True