Makefile: fix make validatepr run from git worktrees

When running `make validatepr` from a git worktree, $(CURDIR)/.git is a file
pointing to the parent git dir outside the bind mount. Mount that dir at its
own path so git inside the container can resolve and not throw ownership errors.

Signed-off-by: Danish Prakash <contact@danishpraka.sh>
This commit is contained in:
Danish Prakash 2026-07-02 20:54:12 +05:30
parent d9a2250d3c
commit ceea48155a
No known key found for this signature in database
GPG key ID: 66820561C42B7C0C

View file

@ -336,9 +336,14 @@ validate: validate-source validate-binaries ## Run all validation checks (lint,
# not automated right now. The hope is that eventually the quay.io/libpod/fedora_podman is multiarch and can replace this
# image in the future.
.PHONY: validatepr
# When run from a git worktree, $(CURDIR)/.git is a file pointing to the parent
# git dir outside the bind mount; also mount that dir at its own path so git
# inside the container can resolve and not throw ownership errors.
validatepr: GIT_COMMON_DIR = $(shell git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)
validatepr: ## Run full PR validation in a container (lint, format, checks)
$(PODMANCMD) run --rm --init --tmpfs /tmp \
-v $(CURDIR):/go/src/github.com/containers/podman \
$(if $(GIT_COMMON_DIR),-v $(GIT_COMMON_DIR):$(GIT_COMMON_DIR)) \
-v validatepr-gocache:/root/.cache/go-build \
-v validatepr-gomodcache:/root/go/pkg/mod \
-v validatepr-lintcache:/root/.cache/golangci-lint \