mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-20 01:24:42 +04:00
Merge pull request #1371 from killuazhu/windows-no-user
Don't use --user when running docker on windows
This commit is contained in:
commit
528c7afd18
2 changed files with 5 additions and 5 deletions
|
|
@ -76,18 +76,18 @@ def install_environment(
|
||||||
os.mkdir(directory)
|
os.mkdir(directory)
|
||||||
|
|
||||||
|
|
||||||
def get_docker_user() -> str: # pragma: win32 no cover
|
def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover
|
||||||
try:
|
try:
|
||||||
return f'{os.getuid()}:{os.getgid()}'
|
return ('-u', f'{os.getuid()}:{os.getgid()}')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return '1000:1000'
|
return ()
|
||||||
|
|
||||||
|
|
||||||
def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
|
def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
|
||||||
return (
|
return (
|
||||||
'docker', 'run',
|
'docker', 'run',
|
||||||
'--rm',
|
'--rm',
|
||||||
'-u', get_docker_user(),
|
*get_docker_user(),
|
||||||
# https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
|
# https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
|
||||||
# The `Z` option tells Docker to label the content with a private
|
# The `Z` option tells Docker to label the content with a private
|
||||||
# unshared label. Only the current container can use a private volume.
|
# unshared label. Only the current container can use a private volume.
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,4 @@ def test_docker_fallback_user():
|
||||||
getuid=invalid_attribute,
|
getuid=invalid_attribute,
|
||||||
getgid=invalid_attribute,
|
getgid=invalid_attribute,
|
||||||
):
|
):
|
||||||
assert docker.get_docker_user() == '1000:1000'
|
assert docker.get_docker_user() == ()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue