mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 01:28:56 +00:00
remove container before deleting image
This commit is contained in:
parent
dac27923bd
commit
37546b9c37
@ -3,13 +3,15 @@ from thefuck.types import Command
|
|||||||
|
|
||||||
|
|
||||||
def test_match():
|
def test_match():
|
||||||
err_response = """
|
err_response = """Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image is being used by running container e5e2591040d1"""
|
||||||
Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image
|
|
||||||
is being used by running container e5e2591040d1
|
|
||||||
"""
|
|
||||||
assert match(Command('docker image rm -f cd809b04b6ff', err_response))
|
assert match(Command('docker image rm -f cd809b04b6ff', err_response))
|
||||||
|
|
||||||
|
|
||||||
def test_get_new_command():
|
def test_get_new_command():
|
||||||
assert get_new_command(Command('docker image rm -f cd809b04b6ff',
|
err_response = """
|
||||||
'')) == 'docker container rm -f e5e2591040d1 && docker image rm -f cd809b04b6ff'
|
Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image
|
||||||
|
is being used by running container e5e2591040d1
|
||||||
|
"""
|
||||||
|
result = get_new_command(Command('docker image rm -f cd809b04b6ff', err_response))
|
||||||
|
expected = 'docker container rm -f e5e2591040d1 && docker image rm -f cd809b04b6ff'
|
||||||
|
assert result == expected
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
from thefuck.utils import for_app, replace_command
|
from thefuck.utils import for_app
|
||||||
|
|
||||||
|
|
||||||
@for_app('docker')
|
@for_app('docker')
|
||||||
def match(command):
|
def match(command):
|
||||||
return 'image is being used by running container' in command.output
|
return ('docker' in command.script
|
||||||
|
and 'image is being used by running container' in command.output)
|
||||||
|
|
||||||
|
|
||||||
def get_new_command(command):
|
def get_new_command(command):
|
||||||
container_id = command.output.split(' ')[-1]
|
container_id = command.output.strip().split(' ')
|
||||||
return 'docker container rm -f {} && {}'.format(container_id, command.script)
|
print(container_id[-1])
|
||||||
|
return 'docker container rm -f {} && {}'.format(container_id[-1], command.script)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user