1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-04-15 07:10:52 +01:00

Add docker_login rule

This commit is contained in:
Inga Feick 2019-03-21 21:56:00 +01:00
parent 1208faaabb
commit c41dfe842d
3 changed files with 29 additions and 0 deletions

View File

@ -190,6 +190,7 @@ following rules are enabled by default:
* `dirty_unzip` – fixes `unzip` command that unzipped in the current directory;
* `django_south_ghost` – adds `--delete-ghost-migrations` to failed because ghosts django south migration;
* `django_south_merge` – adds `--merge` to inconsistent django south migration;
* `docker_login` – executes a `docker login` and repeats the previous command;
* `docker_not_command` – fixes wrong docker commands like `docker tags`;
* `dry` – fixes repetitions like `git git push`;
* `fab_command_not_found` – fix misspelled fabric commands;

View File

@ -0,0 +1,16 @@
from thefuck.rules.docker_login import match, get_new_command
from thefuck.types import Command
def test_match():
err_response = """
Sending build context to Docker daemon 118.8kB
Step 1/6 : FROM baz/baz:nightly
pull access denied for baz/baz, repository does not exist or may require 'docker login'
"""
assert match(Command('docker build -t artifactory:9090/foo/bar:fdb7c6d .', err_response))
assert not match(Command('', ''))
def test_get_new_command():
assert get_new_command(Command('docker build -t artifactory:9090/foo/bar:fdb7c6d .', '')) == 'docker login && docker build -t artifactory:9090/foo/bar:fdb7c6d .'

View File

@ -0,0 +1,12 @@
from thefuck.utils import for_app
@for_app('docker')
def match(command):
return ('docker' in command.script
and "access denied" in command.output
and "may require 'docker login'" in command.output)
def get_new_command(command):
return "docker login && %s" % command.script