mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
the -u option is not necessary on a rootless environment
This commit is contained in:
parent
7c16c3e53f
commit
5c1cd8168a
1 changed files with 12 additions and 4 deletions
|
|
@ -79,11 +79,19 @@ def install_environment(
|
||||||
|
|
||||||
def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover
|
def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover
|
||||||
try:
|
try:
|
||||||
ver_cmd = 'docker', '--version'
|
rootless = False
|
||||||
if subprocess.check_output(ver_cmd).startswith(b'podman version '):
|
output = subprocess.check_output(('docker', 'system', 'info'), text=True)
|
||||||
return ()
|
for line in output.splitlines():
|
||||||
else:
|
# rootless docker has "rootless"
|
||||||
|
# rootless podman has "rootless: true"
|
||||||
|
if line.strip().startswith('rootless'):
|
||||||
|
if not 'false' in line:
|
||||||
|
rootless = True
|
||||||
|
break
|
||||||
|
if not rootless:
|
||||||
return ('-u', f'{os.getuid()}:{os.getgid()}')
|
return ('-u', f'{os.getuid()}:{os.getgid()}')
|
||||||
|
else:
|
||||||
|
return()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue