From 5e0cc8c70325b2aa132751be4b19d81dc21df1d4 Mon Sep 17 00:00:00 2001 From: nvbn Date: Sun, 3 Apr 2016 14:07:39 +0300 Subject: [PATCH] #491: yield possible fixes in `git_branch_exists` rule --- thefuck/rules/git_branch_exists.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/thefuck/rules/git_branch_exists.py b/thefuck/rules/git_branch_exists.py index 882a7fa9..a2c00788 100644 --- a/thefuck/rules/git_branch_exists.py +++ b/thefuck/rules/git_branch_exists.py @@ -1,6 +1,7 @@ import re from thefuck.shells import shell from thefuck.specific.git import git_support +from thefuck.utils import eager @git_support @@ -11,11 +12,12 @@ def match(command): @git_support +@eager def get_new_command(command): branch_name = re.findall( r"fatal: A branch named '([^']*)' already exists.", command.stderr)[0] - return_ = [shell.and_(*cmd_list).format(branch_name) for cmd_list in [ - ['git branch -d {0}', 'git branch {0}'], - ['git branch -D {0}', 'git branch {0}'], - ['git checkout {0}']]] - return return_ + new_command_templates = [['git branch -d {0}', 'git branch {0}'], + ['git branch -D {0}', 'git branch {0}'], + ['git checkout {0}']] + for new_command_template in new_command_templates: + yield shell.and_(*new_command_template).format(branch_name)