Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workaround script for pre-commit/pre-commit#1243 #990

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions sections/new-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,31 @@ run via `boot2docker` are known to be unable to make modifications to files.
See [this repository](https://github.com/pre-commit/pre-commit-docker-flake8)
for an example Docker-based hook.

There is a [known issue](https://github.com/pre-commit/pre-commit/issues/1243)
using rootless podman with this language, such as with `podman-docker`. One
workaround is to place this script (adapted from `podman-docker`) as `docker`
on your `$PATH`, such as `$HOME/.local/bin/docker`.

```bash
#!/bin/bash
[ -e /etc/containers/nodocker ] || \
echo "Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg." >&2

# Check for and drop -u flag -- workaround to https://github.com/pre-commit/pre-commit/issues/1243
args=() # declare array
while [[ "$#" -gt 0 ]]; do
if [[ "$1" == "-u" || "$1" == "--user" ]]; then
echo "Dropping arguments '$1 $2' before passing to podman" >&2
shift 2
else
args+=("$1")
shift 1
fi
done

exec /usr/bin/podman "${args[@]}"
```

### docker_image

A more lightweight approach to `docker` hooks. The `docker_image`
Expand Down
Loading