Skip to content

Commit 201c01f

Browse files
0xcomposurenvbn
authored andcommitted
Adding yay AUR manager to Arch Linux's commands since yaourt is unmaintained and has some security issues. (#907)
1 parent 78ef9ee commit 201c01f

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ The following rules are enabled by default on specific platforms only:
315315
* `brew_unknown_command` – fixes wrong brew commands, for example `brew docto/brew doctor`;
316316
* `brew_update_formula` &ndash; turns `brew update <formula>` into `brew upgrade <formula>`;
317317
* `dnf_no_such_command` &ndash; fixes mistyped DNF commands;
318-
* `pacman` &ndash; installs app with `pacman` if it is not installed (uses `yaourt` if available);
319-
* `pacman_not_found` &ndash; fixes package name with `pacman` or `yaourt`.
318+
* `pacman` &ndash; installs app with `pacman` if it is not installed (uses `yay` or `yaourt` if available);
319+
* `pacman_not_found` &ndash; fixes package name with `pacman`, `yay` or `yaourt`.
320320

321321
The following commands are bundled with *The Fuck*, but are not enabled by
322322
default:

tests/rules/test_pacman_not_found.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@pytest.mark.skipif(not getattr(pacman_not_found, 'enabled_by_default', True),
1212
reason='Skip if pacman is not available')
1313
@pytest.mark.parametrize('command', [
14+
Command('yay -S llc', 'error: target not found: llc'),
1415
Command('yaourt -S llc', 'error: target not found: llc'),
1516
Command('pacman llc', 'error: target not found: llc'),
1617
Command('sudo pacman llc', 'error: target not found: llc')])
@@ -19,6 +20,7 @@ def test_match(command):
1920

2021

2122
@pytest.mark.parametrize('command', [
23+
Command('yay -S llc', 'error: target not found: llc'),
2224
Command('yaourt -S llc', 'error: target not found: llc'),
2325
Command('pacman llc', 'error: target not found: llc'),
2426
Command('sudo pacman llc', 'error: target not found: llc')])
@@ -31,6 +33,7 @@ def test_match_mocked(subp_mock, command):
3133
@pytest.mark.skipif(not getattr(pacman_not_found, 'enabled_by_default', True),
3234
reason='Skip if pacman is not available')
3335
@pytest.mark.parametrize('command, fixed', [
36+
(Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']),
3437
(Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']),
3538
(Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']),
3639
(Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])])
@@ -39,6 +42,7 @@ def test_get_new_command(command, fixed):
3942

4043

4144
@pytest.mark.parametrize('command, fixed', [
45+
(Command('yay -S llc', 'error: target not found: llc'), ['yay -S extra/llvm', 'yay -S extra/llvm35']),
4246
(Command('yaourt -S llc', 'error: target not found: llc'), ['yaourt -S extra/llvm', 'yaourt -S extra/llvm35']),
4347
(Command('pacman -S llc', 'error: target not found: llc'), ['pacman -S extra/llvm', 'pacman -S extra/llvm35']),
4448
(Command('sudo pacman -S llc', 'error: target not found: llc'), ['sudo pacman -S extra/llvm', 'sudo pacman -S extra/llvm35'])])

thefuck/rules/pacman_not_found.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
""" Fixes wrong package names with pacman or yaourt.
22
33
For example the `llc` program is in package `llvm` so this:
4-
yaourt -S llc
4+
yay -S llc
55
should be:
6-
yaourt -S llvm
6+
yay -S llvm
77
"""
88

99
from thefuck.utils import replace_command
@@ -12,7 +12,7 @@
1212

1313
def match(command):
1414
return (command.script_parts
15-
and (command.script_parts[0] in ('pacman', 'yaourt')
15+
and (command.script_parts[0] in ('pacman', 'yay', 'yaourt')
1616
or command.script_parts[0:2] == ['sudo', 'pacman'])
1717
and 'error: target not found:' in command.output)
1818

thefuck/specific/archlinux.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def get_pkgfile(command):
3232

3333

3434
def archlinux_env():
35-
if utils.which('yaourt'):
35+
if utils.which('yay'):
36+
pacman = 'yay'
37+
elif utils.which('yaourt'):
3638
pacman = 'yaourt'
3739
elif utils.which('pacman'):
3840
pacman = 'sudo pacman'

0 commit comments

Comments
 (0)