#N/A Add a new rule git_branch_exists

This commit is contained in:
Pablo Santiago Blum de Aguiar
2016-04-02 23:57:43 -03:00
parent d102af41d9
commit 0c98053f74
3 changed files with 55 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import re
from thefuck.shells import shell
from thefuck.specific.git import git_support
@git_support
def match(command):
return ('branch' in command.script
and "fatal: A branch named '" in command.stderr
and " already exists." in command.stderr)
@git_support
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_