From 89bc2e9759075ea851eef2ef118ab1cbc4db38d2 Mon Sep 17 00:00:00 2001 From: Stef Pletinck Date: Thu, 5 Oct 2017 18:44:04 +0200 Subject: [PATCH 1/4] fixed #670 --- thefuck/rules/git_remote_delete.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 thefuck/rules/git_remote_delete.py diff --git a/thefuck/rules/git_remote_delete.py b/thefuck/rules/git_remote_delete.py new file mode 100644 index 00000000..ce316da1 --- /dev/null +++ b/thefuck/rules/git_remote_delete.py @@ -0,0 +1,12 @@ +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") From f372f3d56cecb3b00ccee6f3b74935aece4ba013 Mon Sep 17 00:00:00 2001 From: Stef Pletinck Date: Sat, 7 Oct 2017 13:59:32 +0200 Subject: [PATCH 2/4] Added test --- tests/rules/test_git_remote_delete.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/rules/test_git_remote_delete.py 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' From b6ecaf4d867073d1f08df5072edea707a864728b Mon Sep 17 00:00:00 2001 From: Stef Pletinck Date: Sat, 7 Oct 2017 13:59:51 +0200 Subject: [PATCH 3/4] Enabled by default --- thefuck/rules/git_remote_delete.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/thefuck/rules/git_remote_delete.py b/thefuck/rules/git_remote_delete.py index ce316da1..4cde87b3 100644 --- a/thefuck/rules/git_remote_delete.py +++ b/thefuck/rules/git_remote_delete.py @@ -10,3 +10,6 @@ def match(command): @git_support def get_new_command(command): return replace_argument(command.script, "delete", "remove") + + +enabled_by_default = True From f24110de5670ca98da4a968d26d75184eb3399d5 Mon Sep 17 00:00:00 2001 From: Stef Pletinck Date: Sat, 7 Oct 2017 14:01:26 +0200 Subject: [PATCH 4/4] added readme line --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7f0757b5..8809b497 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