Skip to content

Commit

Permalink
Merge ec2dc79 into 40ab4eb
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcomposure committed Apr 26, 2019
2 parents 40ab4eb + ec2dc79 commit 3e0b095
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -315,8 +315,8 @@ The following rules are enabled by default on specific platforms only:
* `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`;
* `brew_update_formula` &ndash; turns `brew update <formula>` into `brew upgrade <formula>`;
* `dnf_no_such_command` &ndash; fixes mistyped DNF commands;
* `pacman` &ndash; installs app with `pacman` if it is not installed (uses `yaourt` if available);
* `pacman_not_found` &ndash; fixes package name with `pacman` or `yaourt`.
* `pacman` &ndash; installs app with `pacman` if it is not installed (uses `yay` or `yaourt` if available);
* `pacman_not_found` &ndash; fixes package name with `pacman`, `yay` or `yaourt`.

The following commands are bundled with *The Fuck*, but are not enabled by
default:
Expand Down
4 changes: 4 additions & 0 deletions tests/rules/test_pacman_not_found.py
Expand Up @@ -11,6 +11,7 @@
@pytest.mark.skipif(not getattr(pacman_not_found, 'enabled_by_default', True),
reason='Skip if pacman is not available')
@pytest.mark.parametrize('command', [
Command('yay -S llc', 'error: target not found: llc'),
Command('yaourt -S llc', 'error: target not found: llc'),
Command('pacman llc', 'error: target not found: llc'),
Command('sudo pacman llc', 'error: target not found: llc')])
Expand All @@ -19,6 +20,7 @@ def test_match(command):


@pytest.mark.parametrize('command', [
Command('yay -S llc', 'error: target not found: llc'),
Command('yaourt -S llc', 'error: target not found: llc'),
Command('pacman llc', 'error: target not found: llc'),
Command('sudo pacman llc', 'error: target not found: llc')])
Expand All @@ -31,6 +33,7 @@ def test_match_mocked(subp_mock, command):
@pytest.mark.skipif(not getattr(pacman_not_found, 'enabled_by_default', True),
reason='Skip if pacman is not available')
@pytest.mark.parametrize('command, fixed', [
(Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']),
(Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']),
(Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']),
(Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])])
Expand All @@ -39,6 +42,7 @@ def test_get_new_command(command, fixed):


@pytest.mark.parametrize('command, fixed', [
(Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']),
(Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']),
(Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']),
(Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])])
Expand Down
6 changes: 3 additions & 3 deletions thefuck/rules/pacman_not_found.py
@@ -1,9 +1,9 @@
""" Fixes wrong package names with pacman or yaourt.
For example the `llc` program is in package `llvm` so this:
yaourt -S llc
yay -S llc
should be:
yaourt -S llvm
yay -S llvm
"""

from thefuck.utils import replace_command
Expand All @@ -12,7 +12,7 @@

def match(command):
return (command.script_parts
and (command.script_parts[0] in ('pacman', 'yaourt')
and (command.script_parts[0] in ('pacman', 'yay', 'yaourt')
or command.script_parts[0:2] == ['sudo', 'pacman'])
and 'error: target not found:' in command.output)

Expand Down
4 changes: 3 additions & 1 deletion thefuck/specific/archlinux.py
Expand Up @@ -32,7 +32,9 @@ def get_pkgfile(command):


def archlinux_env():
if utils.which('yaourt'):
if utils.which('yay'):
pacman = 'yay'
elif utils.which('yaourt'):
pacman = 'yaourt'
elif utils.which('pacman'):
pacman = 'sudo pacman'
Expand Down

0 comments on commit 3e0b095

Please sign in to comment.