From 84c16fb69a4c0abcb9fe1c90787076800320a950 Mon Sep 17 00:00:00 2001 From: ik1ne <3996272+ik1ne@users.noreply.github.com> Date: Tue, 3 Sep 2019 02:16:40 +0900 Subject: [PATCH 1/5] Change: rules_git_checkout handling branch names with slashes & Remote HEAD. (#944) * Add: Test for branch names with slashes & Remote HEAD. * - Add: Handling for removing remote HEAD. - Change: Improved handling for branches with slash in their names. --- tests/rules/test_git_checkout.py | 5 +++++ thefuck/rules/git_checkout.py | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/rules/test_git_checkout.py b/tests/rules/test_git_checkout.py index 20fff03c..c54be16c 100644 --- a/tests/rules/test_git_checkout.py +++ b/tests/rules/test_git_checkout.py @@ -39,6 +39,11 @@ def test_not_match(command): (b'', []), (b'* 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'* master\n just-another-branch', ['master', 'just-another-branch']), (b'* master\n remotes/origin/master\n just-another-branch', diff --git a/thefuck/rules/git_checkout.py b/thefuck/rules/git_checkout.py index b500652f..6345cbc3 100644 --- a/thefuck/rules/git_checkout.py +++ b/thefuck/rules/git_checkout.py @@ -18,10 +18,12 @@ def get_branches(): stdout=subprocess.PIPE) for line in proc.stdout.readlines(): line = line.decode('utf-8') + if '->' in line: # Remote HEAD like b' remotes/origin/HEAD -> origin/master' + continue if line.startswith('*'): line = line.split(' ')[1] - if '/' in line: - line = line.split('/')[-1] + if line.strip().startswith('remotes/'): + line = '/'.join(line.split('/')[2:]) yield line.strip() From c53676e42f0ffde90f5eaa1ecda82599dc87a40f Mon Sep 17 00:00:00 2001 From: Shaoyuan CHEN Date: Tue, 3 Sep 2019 01:17:48 +0800 Subject: [PATCH 2/5] change sudo.py pattern to lowercase (#947) --- thefuck/rules/sudo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thefuck/rules/sudo.py b/thefuck/rules/sudo.py index 4723de0b..a2980216 100644 --- a/thefuck/rules/sudo.py +++ b/thefuck/rules/sudo.py @@ -21,7 +21,7 @@ patterns = ['permission denied', 'edspermissionerror', 'you don\'t have write permissions', 'use `sudo`', - 'SudoRequiredError', + 'sudorequirederror', 'error: insufficient privileges'] From 3bbd0e94633ca68c7c5e7919bd6cbf4f29aee4c3 Mon Sep 17 00:00:00 2001 From: thatneat Date: Tue, 17 Sep 2019 11:02:45 -0700 Subject: [PATCH 3/5] Correct "apt uninstall" -> "apt remove" (#950) * Correct "apt uninstall" -> "apt remove" * remove unused import --- tests/rules/test_apt_invalid_operation.py | 2 ++ thefuck/rules/apt_invalid_operation.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/rules/test_apt_invalid_operation.py b/tests/rules/test_apt_invalid_operation.py index 7b9fcde3..bc7b8c9b 100644 --- a/tests/rules/test_apt_invalid_operation.py +++ b/tests/rules/test_apt_invalid_operation.py @@ -116,6 +116,8 @@ def test_get_operations(set_help, app, help_text, operations): apt_get_help, 'apt-get install vim'), ('apt saerch vim', invalid_operation('saerch'), 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): set_help(help_text) diff --git a/thefuck/rules/apt_invalid_operation.py b/thefuck/rules/apt_invalid_operation.py index 076109ba..c2564c03 100644 --- a/thefuck/rules/apt_invalid_operation.py +++ b/thefuck/rules/apt_invalid_operation.py @@ -53,5 +53,10 @@ def _get_operations(app): @sudo_support def get_new_command(command): invalid_operation = command.output.split()[-1] - operations = _get_operations(command.script_parts[0]) - return replace_command(command, invalid_operation, operations) + + if invalid_operation == 'uninstall': + return [command.script.replace('uninstall', 'remove')] + + else: + operations = _get_operations(command.script_parts[0]) + return replace_command(command, invalid_operation, operations) From 8ff2336293196a3670444f4829c8bbc2f148834d Mon Sep 17 00:00:00 2001 From: spidermanir Date: Sat, 5 Oct 2019 00:10:23 +0330 Subject: [PATCH 4/5] Change The file --- tests/rules/test_dnf_no_such_command.py | 2 ++ thefuck/rules/dnf_no_such_command.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/rules/test_dnf_no_such_command.py b/tests/rules/test_dnf_no_such_command.py index 6229828f..fad9b079 100644 --- a/tests/rules/test_dnf_no_such_command.py +++ b/tests/rules/test_dnf_no_such_command.py @@ -184,6 +184,8 @@ def test_get_operations(set_help): 'dnf install vim'), ('dnf saerch vim', invalid_command('saerch'), 'dnf search vim'), + ('dnf uninstall vim', invalid_command('uninstall'), + 'dnf remove vim'), ]) def test_get_new_command(set_help, output, script, result): set_help(help_text) diff --git a/thefuck/rules/dnf_no_such_command.py b/thefuck/rules/dnf_no_such_command.py index 579f5781..8f1f283c 100644 --- a/thefuck/rules/dnf_no_such_command.py +++ b/thefuck/rules/dnf_no_such_command.py @@ -30,8 +30,11 @@ def _get_operations(): @sudo_support def get_new_command(command): - misspelled_command = regex.findall(command.output)[0] - return replace_command(command, misspelled_command, _get_operations()) + if misspelled_command == 'uninstall': + return [command.script.replace('uninstall','remove') + else: + misspelled_command = regex.findall(command.output)[0] + return replace_command(command, misspelled_command, _get_operations()) enabled_by_default = dnf_available From 46439e0ee421f05af1a93b93f9a0c118119bf865 Mon Sep 17 00:00:00 2001 From: spidermanir Date: Sat, 5 Oct 2019 00:17:43 +0330 Subject: [PATCH 5/5] sry edit is false --- thefuck/rules/dnf_no_such_command.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/thefuck/rules/dnf_no_such_command.py b/thefuck/rules/dnf_no_such_command.py index 8f1f283c..579f5781 100644 --- a/thefuck/rules/dnf_no_such_command.py +++ b/thefuck/rules/dnf_no_such_command.py @@ -30,11 +30,8 @@ def _get_operations(): @sudo_support def get_new_command(command): - if misspelled_command == 'uninstall': - return [command.script.replace('uninstall','remove') - else: - misspelled_command = regex.findall(command.output)[0] - return replace_command(command, misspelled_command, _get_operations()) + misspelled_command = regex.findall(command.output)[0] + return replace_command(command, misspelled_command, _get_operations()) enabled_by_default = dnf_available