From 660422806cc6d53955b75e13d1cd4b4751d3f60c Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Mon, 1 Jun 2015 23:52:41 +0300 Subject: [PATCH 1/2] Add git_branch_list rule --- thefuck/rules/git_branch_list.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 thefuck/rules/git_branch_list.py diff --git a/thefuck/rules/git_branch_list.py b/thefuck/rules/git_branch_list.py new file mode 100644 index 00000000..e0a2320c --- /dev/null +++ b/thefuck/rules/git_branch_list.py @@ -0,0 +1,10 @@ +from thefuck import shells + + +def match(command, settings): + # catches "git branch list" in place of "git branch" + return command.script.split() == 'git branch list'.split() + + +def get_new_command(command, settings): + return shells.and_('git branch --delete list', 'git branch') From ba9214f7fca609948130d2ae56bb19805b79d59c Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Tue, 2 Jun 2015 00:14:20 +0300 Subject: [PATCH 2/2] Add a test for git_branch_list rule --- tests/rules/test_git_branch_list.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/rules/test_git_branch_list.py diff --git a/tests/rules/test_git_branch_list.py b/tests/rules/test_git_branch_list.py new file mode 100644 index 00000000..e1d1f23f --- /dev/null +++ b/tests/rules/test_git_branch_list.py @@ -0,0 +1,18 @@ +from thefuck import shells +from thefuck.rules.git_branch_list import match, get_new_command +from tests.utils import Command + +def test_match(): + assert match(Command('git branch list'), None) + + +def test_not_match(): + assert not match(Command(), None) + assert not match(Command('git commit'), None) + assert not match(Command('git branch'), None) + assert not match(Command('git stash list'), None) + + +def test_get_new_command(): + assert (get_new_command(Command('git branch list'), None) == + shells.and_('git branch --delete list', 'git branch'))