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