mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-22 12:58:33 +00:00
#491: yield possible fixes in git_branch_exists
rule
This commit is contained in:
parent
1aa2ec1795
commit
5e0cc8c703
@ -1,6 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
from thefuck.shells import shell
|
from thefuck.shells import shell
|
||||||
from thefuck.specific.git import git_support
|
from thefuck.specific.git import git_support
|
||||||
|
from thefuck.utils import eager
|
||||||
|
|
||||||
|
|
||||||
@git_support
|
@git_support
|
||||||
@ -11,11 +12,12 @@ def match(command):
|
|||||||
|
|
||||||
|
|
||||||
@git_support
|
@git_support
|
||||||
|
@eager
|
||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
branch_name = re.findall(
|
branch_name = re.findall(
|
||||||
r"fatal: A branch named '([^']*)' already exists.", command.stderr)[0]
|
r"fatal: A branch named '([^']*)' already exists.", command.stderr)[0]
|
||||||
return_ = [shell.and_(*cmd_list).format(branch_name) for cmd_list in [
|
new_command_templates = [['git branch -d {0}', 'git branch {0}'],
|
||||||
['git branch -d {0}', 'git branch {0}'],
|
|
||||||
['git branch -D {0}', 'git branch {0}'],
|
['git branch -D {0}', 'git branch {0}'],
|
||||||
['git checkout {0}']]]
|
['git checkout {0}']]
|
||||||
return return_
|
for new_command_template in new_command_templates:
|
||||||
|
yield shell.and_(*new_command_template).format(branch_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user