mirror of
https://github.com/nvbn/thefuck.git
synced 2025-09-19 19:52:31 +01:00
Merge pull request #657 from josephfrazier/git_not_command-wording
Update stderr wording of git_not_command
This commit is contained in:
@@ -7,7 +7,7 @@ from tests.utils import Command
|
|||||||
def git_not_command():
|
def git_not_command():
|
||||||
return """git: 'brnch' is not a git command. See 'git --help'.
|
return """git: 'brnch' is not a git command. See 'git --help'.
|
||||||
|
|
||||||
Did you mean this?
|
The most similar command is
|
||||||
branch
|
branch
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ branch
|
|||||||
def git_not_command_one_of_this():
|
def git_not_command_one_of_this():
|
||||||
return """git: 'st' is not a git command. See 'git --help'.
|
return """git: 'st' is not a git command. See 'git --help'.
|
||||||
|
|
||||||
Did you mean one of these?
|
The most similar commands are
|
||||||
status
|
status
|
||||||
reset
|
reset
|
||||||
stage
|
stage
|
||||||
@@ -29,7 +29,7 @@ stats
|
|||||||
def git_not_command_closest():
|
def git_not_command_closest():
|
||||||
return '''git: 'tags' is not a git command. See 'git --help'.
|
return '''git: 'tags' is not a git command. See 'git --help'.
|
||||||
|
|
||||||
Did you mean one of these?
|
The most similar commands are
|
||||||
\tstage
|
\tstage
|
||||||
\ttag
|
\ttag
|
||||||
'''
|
'''
|
||||||
|
@@ -6,12 +6,13 @@ from thefuck.specific.git import git_support
|
|||||||
@git_support
|
@git_support
|
||||||
def match(command):
|
def match(command):
|
||||||
return (" is not a git command. See 'git --help'." in command.stderr
|
return (" is not a git command. See 'git --help'." in command.stderr
|
||||||
and 'Did you mean' in command.stderr)
|
and ('The most similar command' in command.stderr
|
||||||
|
or 'Did you mean' in command.stderr))
|
||||||
|
|
||||||
|
|
||||||
@git_support
|
@git_support
|
||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
|
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
|
||||||
command.stderr)[0]
|
command.stderr)[0]
|
||||||
matched = get_all_matched_commands(command.stderr)
|
matched = get_all_matched_commands(command.stderr, ['The most similar command', 'Did you mean'])
|
||||||
return replace_command(command, broken_cmd, matched)
|
return replace_command(command, broken_cmd, matched)
|
||||||
|
@@ -141,12 +141,17 @@ def eager(fn, *args, **kwargs):
|
|||||||
|
|
||||||
@eager
|
@eager
|
||||||
def get_all_matched_commands(stderr, separator='Did you mean'):
|
def get_all_matched_commands(stderr, separator='Did you mean'):
|
||||||
|
if not isinstance(separator, list):
|
||||||
|
separator = [separator]
|
||||||
should_yield = False
|
should_yield = False
|
||||||
for line in stderr.split('\n'):
|
for line in stderr.split('\n'):
|
||||||
if separator in line:
|
for sep in separator:
|
||||||
should_yield = True
|
if sep in line:
|
||||||
elif should_yield and line:
|
should_yield = True
|
||||||
yield line.strip()
|
break
|
||||||
|
else:
|
||||||
|
if should_yield and line:
|
||||||
|
yield line.strip()
|
||||||
|
|
||||||
|
|
||||||
def replace_command(command, broken, matched):
|
def replace_command(command, broken, matched):
|
||||||
|
Reference in New Issue
Block a user