Skip to content

Commit 951617b

Browse files
authored
feat: when run make precommit-local, check container runtime (#187)
Signed-off-by: yuluo-yx <[email protected]>
1 parent 1067aae commit 951617b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tools/make/pre-commit.mk

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,21 @@ precommit-check:
3131
# bash
3232
# and then, run `pre-commit install && pre-commit run --all-files` command
3333
precommit-local:
34-
@if ! docker image inspect ${PRECOMMIT_CONTAINER} > /dev/null 2>&1; then \
34+
@if command -v docker > /dev/null 2>&1; then \
35+
CONTAINER_CMD=docker; \
36+
elif command -v podman > /dev/null 2>&1; then \
37+
CONTAINER_CMD=podman; \
38+
else \
39+
echo "Error: Neither docker nor podman is installed. Please install one of them."; \
40+
exit 1; \
41+
fi; \
42+
if ! $$CONTAINER_CMD image inspect ${PRECOMMIT_CONTAINER} > /dev/null 2>&1; then \
3543
echo "Image not found locally. Pulling..."; \
36-
docker pull ${PRECOMMIT_CONTAINER}; \
44+
$$CONTAINER_CMD pull ${PRECOMMIT_CONTAINER}; \
3745
else \
3846
echo "Image found locally. Skipping pull."; \
39-
fi
40-
docker run --rm \
47+
fi; \
48+
$$CONTAINER_CMD run --rm \
4149
-v $(shell pwd):/app \
4250
-w /app \
4351
--name precommit-container ${PRECOMMIT_CONTAINER} \

0 commit comments

Comments
 (0)