mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-07 13:41:21 +00:00
Merge branch 'master' of https://github.com/spidermanir/thefuck
This commit is contained in:
commit
bf3454d272
@ -116,6 +116,8 @@ def test_get_operations(set_help, app, help_text, operations):
|
|||||||
apt_get_help, 'apt-get install vim'),
|
apt_get_help, 'apt-get install vim'),
|
||||||
('apt saerch vim', invalid_operation('saerch'),
|
('apt saerch vim', invalid_operation('saerch'),
|
||||||
apt_help, 'apt search vim'),
|
apt_help, 'apt search vim'),
|
||||||
|
('apt uninstall vim', invalid_operation('uninstall'),
|
||||||
|
apt_help, 'apt remove vim'),
|
||||||
])
|
])
|
||||||
def test_get_new_command(set_help, output, script, help_text, result):
|
def test_get_new_command(set_help, output, script, help_text, result):
|
||||||
set_help(help_text)
|
set_help(help_text)
|
||||||
|
@ -184,6 +184,8 @@ def test_get_operations(set_help):
|
|||||||
'dnf install vim'),
|
'dnf install vim'),
|
||||||
('dnf saerch vim', invalid_command('saerch'),
|
('dnf saerch vim', invalid_command('saerch'),
|
||||||
'dnf search vim'),
|
'dnf search vim'),
|
||||||
|
('dnf uninstall vim', invalid_command('uninstall'),
|
||||||
|
'dnf remove vim'),
|
||||||
])
|
])
|
||||||
def test_get_new_command(set_help, output, script, result):
|
def test_get_new_command(set_help, output, script, result):
|
||||||
set_help(help_text)
|
set_help(help_text)
|
||||||
|
@ -39,6 +39,11 @@ def test_not_match(command):
|
|||||||
(b'', []),
|
(b'', []),
|
||||||
(b'* master', ['master']),
|
(b'* master', ['master']),
|
||||||
(b' remotes/origin/master', ['master']),
|
(b' remotes/origin/master', ['master']),
|
||||||
|
(b' remotes/origin/test/1', ['test/1']),
|
||||||
|
(b' remotes/origin/test/1/2/3', ['test/1/2/3']),
|
||||||
|
(b' test/1', ['test/1']),
|
||||||
|
(b' test/1/2/3', ['test/1/2/3']),
|
||||||
|
(b' remotes/origin/HEAD -> origin/master', []),
|
||||||
(b' just-another-branch', ['just-another-branch']),
|
(b' just-another-branch', ['just-another-branch']),
|
||||||
(b'* master\n just-another-branch', ['master', 'just-another-branch']),
|
(b'* master\n just-another-branch', ['master', 'just-another-branch']),
|
||||||
(b'* master\n remotes/origin/master\n just-another-branch',
|
(b'* master\n remotes/origin/master\n just-another-branch',
|
||||||
|
@ -53,5 +53,10 @@ def _get_operations(app):
|
|||||||
@sudo_support
|
@sudo_support
|
||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
invalid_operation = command.output.split()[-1]
|
invalid_operation = command.output.split()[-1]
|
||||||
|
|
||||||
|
if invalid_operation == 'uninstall':
|
||||||
|
return [command.script.replace('uninstall', 'remove')]
|
||||||
|
|
||||||
|
else:
|
||||||
operations = _get_operations(command.script_parts[0])
|
operations = _get_operations(command.script_parts[0])
|
||||||
return replace_command(command, invalid_operation, operations)
|
return replace_command(command, invalid_operation, operations)
|
||||||
|
@ -18,10 +18,12 @@ def get_branches():
|
|||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
for line in proc.stdout.readlines():
|
for line in proc.stdout.readlines():
|
||||||
line = line.decode('utf-8')
|
line = line.decode('utf-8')
|
||||||
|
if '->' in line: # Remote HEAD like b' remotes/origin/HEAD -> origin/master'
|
||||||
|
continue
|
||||||
if line.startswith('*'):
|
if line.startswith('*'):
|
||||||
line = line.split(' ')[1]
|
line = line.split(' ')[1]
|
||||||
if '/' in line:
|
if line.strip().startswith('remotes/'):
|
||||||
line = line.split('/')[-1]
|
line = '/'.join(line.split('/')[2:])
|
||||||
yield line.strip()
|
yield line.strip()
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ patterns = ['permission denied',
|
|||||||
'edspermissionerror',
|
'edspermissionerror',
|
||||||
'you don\'t have write permissions',
|
'you don\'t have write permissions',
|
||||||
'use `sudo`',
|
'use `sudo`',
|
||||||
'SudoRequiredError',
|
'sudorequirederror',
|
||||||
'error: insufficient privileges']
|
'error: insufficient privileges']
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user