From 79528ec13edabe842aa0340445affe5044756765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20Flore-Th=C3=A9bault?= Date: Thu, 4 Jun 2020 10:11:03 +0200 Subject: [PATCH] Not just output, move this whole thing out. --- pre_commit/languages/docker.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pre_commit/languages/docker.py b/pre_commit/languages/docker.py index eea1bdcd..72a98ea5 100644 --- a/pre_commit/languages/docker.py +++ b/pre_commit/languages/docker.py @@ -82,14 +82,14 @@ def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover ('docker', 'system', 'info'), text=True, ) + for line in output.splitlines(): + # rootless docker has "rootless" + # rootless podman has "rootless: true" + if line.strip().startswith('rootless'): + if 'false' not in line: + return () # no -u for rootless + break try: - for line in output.splitlines(): - # rootless docker has "rootless" - # rootless podman has "rootless: true" - if line.strip().startswith('rootless'): - if 'false' not in line: - return () # no -u for rootless - break return ('-u', f'{os.getuid()}:{os.getgid()}') except AttributeError: return ()