mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Support docker hooks with args
This commit is contained in:
parent
58df7c06e1
commit
b7bd825e15
3 changed files with 23 additions and 3 deletions
|
|
@ -81,14 +81,17 @@ def run_hook(repo_cmd_runner, hook, file_args):
|
|||
# Rebuild the docker image in case it has gone missing, as many people do
|
||||
# automated cleanup of docker images.
|
||||
build_docker_image(repo_cmd_runner, pull=False)
|
||||
|
||||
entry_parts = hook['entry'].split(' ')
|
||||
entry_executable, entry_args = entry_parts[0], entry_parts[1:]
|
||||
|
||||
cmd = (
|
||||
'docker', 'run',
|
||||
'--rm',
|
||||
'-u', '{}:{}'.format(os.getuid(), os.getgid()),
|
||||
'-v', '{}:/src:rw'.format(os.getcwd()),
|
||||
'--workdir', '/src',
|
||||
'--entrypoint', hook['entry'],
|
||||
'--entrypoint', entry_executable,
|
||||
docker_tag(repo_cmd_runner)
|
||||
)
|
||||
|
||||
return xargs(cmd + tuple(hook['args']), file_args)
|
||||
return xargs(cmd + tuple(entry_args) + tuple(hook['args']), file_args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue