mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 12:06:04 +00:00
Closes https://github.com/nvbn/thefuck/issues/728
This commit is contained in:
parent
8fb5ddefb6
commit
10ac1a3b38
@ -218,6 +218,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
||||
* `grunt_task_not_found` – fixes misspelled `grunt` commands;
|
||||
* `gulp_not_task` – fixes misspelled `gulp` tasks;
|
||||
* `has_exists_script` – prepends `./` when script/binary exists;
|
||||
* `heroku_multiple_apps` – add `--app <app>` to `heroku` commands like `heroku pg`;
|
||||
* `heroku_not_command` – fixes wrong `heroku` commands like `heroku log`;
|
||||
* `history` – tries to replace command with most similar command from history;
|
||||
* `hostscli` – tries to fix `hostscli` usage;
|
||||
|
55
tests/rules/test_heroku_multiple_apps.py
Normal file
55
tests/rules/test_heroku_multiple_apps.py
Normal file
@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pytest
|
||||
from thefuck.types import Command
|
||||
from thefuck.rules.heroku_multiple_apps import match, get_new_command
|
||||
|
||||
|
||||
suggest_output = '''
|
||||
▸ Multiple apps in git remotes
|
||||
▸ Usage: --remote heroku-dev
|
||||
▸ or: --app myapp-dev
|
||||
▸ Your local git repository has more than 1 app referenced in git remotes.
|
||||
▸ Because of this, we can't determine which app you want to run this command against.
|
||||
▸ Specify the app you want with --app or --remote.
|
||||
▸ Heroku remotes in repo:
|
||||
▸ myapp (heroku)
|
||||
▸ myapp-dev (heroku-dev)
|
||||
▸
|
||||
▸ https://devcenter.heroku.com/articles/multiple-environments
|
||||
'''
|
||||
|
||||
not_match_output = '''
|
||||
=== HEROKU_POSTGRESQL_TEAL_URL, DATABASE_URL
|
||||
Plan: Hobby-basic
|
||||
Status: Available
|
||||
Connections: 20/20
|
||||
PG Version: 9.6.4
|
||||
Created: 2017-01-01 00:00 UTC
|
||||
Data Size: 99.9 MB
|
||||
Tables: 99
|
||||
Rows: 12345/10000000 (In compliance)
|
||||
Fork/Follow: Unsupported
|
||||
Rollback: Unsupported
|
||||
Continuous Protection: Off
|
||||
Add-on: postgresql-round-12345
|
||||
'''
|
||||
|
||||
|
||||
@pytest.mark.parametrize('cmd', ['pg'])
|
||||
def test_match(cmd):
|
||||
assert match(
|
||||
Command('heroku {}'.format(cmd), suggest_output))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('script, output', [
|
||||
('heroku pg', not_match_output)])
|
||||
def test_not_match(script, output):
|
||||
assert not match(Command(script, output))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('cmd, result', [
|
||||
('pg', ['heroku pg --app myapp', 'heroku pg --app myapp-dev'])])
|
||||
def test_get_new_command(cmd, result):
|
||||
command = Command('heroku {}'.format(cmd), suggest_output)
|
||||
assert get_new_command(command) == result
|
12
thefuck/rules/heroku_multiple_apps.py
Normal file
12
thefuck/rules/heroku_multiple_apps.py
Normal file
@ -0,0 +1,12 @@
|
||||
import re
|
||||
from thefuck.utils import for_app
|
||||
|
||||
|
||||
@for_app('heroku')
|
||||
def match(command):
|
||||
return 'https://devcenter.heroku.com/articles/multiple-environments' in command.output
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
apps = re.findall('([^ ]*) \([^)]*\)', command.output)
|
||||
return [command.script + ' --app ' + app for app in apps]
|
Loading…
x
Reference in New Issue
Block a user