Skip to content
Prev Previous commit
Next Next commit
add AttributeError again
  • Loading branch information
themr0c committed Jun 3, 2020
commit 4416c3d51220846e9de9624735f6943744388bda
24 changes: 15 additions & 9 deletions pre_commit/languages/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,21 @@ def install_environment(


def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover
output = subprocess.check_output(('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 not 'false' in line:
return () # no -u for rootless
break
return ('-u', f'{os.getuid()}:{os.getgid()}')
try:
output = subprocess.check_output(
Comment thread
themr0c marked this conversation as resolved.
Outdated
('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
Comment thread
themr0c marked this conversation as resolved.
Outdated
return ('-u', f'{os.getuid()}:{os.getgid()}')
except AttributeError:
return ()


def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
Expand Down