kopia lustrzana https://github.com/jupyterhub/repo2docker
Remove maybe_cleanup util function
It was used in exactly one place, and could be inlined with minimal loss of claritypull/494/head
rodzic
30e69bccee
commit
ee9b150ef8
|
@ -35,7 +35,7 @@ from .buildpacks import (
|
||||||
)
|
)
|
||||||
from . import contentproviders
|
from . import contentproviders
|
||||||
from .utils import (
|
from .utils import (
|
||||||
ByteSpecification, maybe_cleanup, is_valid_docker_image_name,
|
ByteSpecification, is_valid_docker_image_name,
|
||||||
validate_and_generate_port_mapping, chdir
|
validate_and_generate_port_mapping, chdir
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -703,9 +703,7 @@ class Repo2Docker(Application):
|
||||||
else:
|
else:
|
||||||
checkout_path = self.git_workdir
|
checkout_path = self.git_workdir
|
||||||
|
|
||||||
# keep as much as possible in the context manager to make sure we
|
try:
|
||||||
# cleanup if things go wrong
|
|
||||||
with maybe_cleanup(checkout_path, self.cleanup_checkout):
|
|
||||||
self.fetch(self.repo, self.ref, checkout_path)
|
self.fetch(self.repo, self.ref, checkout_path)
|
||||||
|
|
||||||
if self.subdir:
|
if self.subdir:
|
||||||
|
@ -751,6 +749,10 @@ class Repo2Docker(Application):
|
||||||
else:
|
else:
|
||||||
self.log.info(json.dumps(l),
|
self.log.info(json.dumps(l),
|
||||||
extra=dict(phase='building'))
|
extra=dict(phase='building'))
|
||||||
|
finally:
|
||||||
|
# Cheanup checkout if necessary
|
||||||
|
if self.cleanup_checkout:
|
||||||
|
shutil.rmtree(checkout_path, ignore_errors=True)
|
||||||
|
|
||||||
if self.push:
|
if self.push:
|
||||||
self.push_image()
|
self.push_image()
|
||||||
|
|
|
@ -69,14 +69,6 @@ def chdir(path):
|
||||||
os.chdir(old_dir)
|
os.chdir(old_dir)
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def maybe_cleanup(path, cleanup=False):
|
|
||||||
"""Delete the directory at passed path if cleanup flag is True."""
|
|
||||||
yield
|
|
||||||
if cleanup:
|
|
||||||
shutil.rmtree(path, ignore_errors=True)
|
|
||||||
|
|
||||||
|
|
||||||
def validate_and_generate_port_mapping(port_mapping):
|
def validate_and_generate_port_mapping(port_mapping):
|
||||||
"""
|
"""
|
||||||
Validate the port mapping list and return a list of validated tuples.
|
Validate the port mapping list and return a list of validated tuples.
|
||||||
|
|
Ładowanie…
Reference in New Issue