From 865ef18f3aac1b8b8f6b789e972e4c8fee957d8b Mon Sep 17 00:00:00 2001 From: ffranr Date: Wed, 31 Dec 2025 00:32:51 +0000 Subject: [PATCH] makefile: mount Git metadata for worktree support in Docker lint runs Golangci-lint uses `issues.new-from-rev` to compare against Git history, but worktrees store .git metadata outside the worktree root. When lint ran in Docker, that history wasn't mounted, causing new-from-rev filtering to fail. Detect the Git dir and common dir via `git rev-parse` and bind-mount them into the container when they are absolute and distinct. This preserves existing cache mounts and maintains consistent behavior across local and CI environments. --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Makefile b/Makefile index 454ba4085..412508e8b 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,22 @@ ifneq ($(workers),) LINT_WORKERS = --concurrency=$(workers) endif +# Worktree support: golangci-lint's issues.new-from-rev compares against git +# history, but worktrees keep .git metadata outside the worktree root. When +# lint runs in Docker without those dirs mounted, new-from-rev cannot resolve, +# so we bind-mount the git dir/common dir into the container. +GIT_DIR := $(shell git rev-parse --git-dir 2>/dev/null) +GIT_COMMON_DIR := $(shell git rev-parse --git-common-dir 2>/dev/null) +DOCKER_GIT_MOUNTS := +ifneq ($(filter /%,$(GIT_DIR)),) +DOCKER_GIT_MOUNTS += -v $(GIT_DIR):$(GIT_DIR) +endif +ifneq ($(filter /%,$(GIT_COMMON_DIR)),) +ifneq ($(GIT_COMMON_DIR),$(GIT_DIR)) +DOCKER_GIT_MOUNTS += -v $(GIT_COMMON_DIR):$(GIT_COMMON_DIR) +endif +endif + # Docker cache mounting strategy: # - CI (GitHub Actions): Use bind mounts to host paths that GA caches persist. # - Local: Use Docker named volumes (much faster on macOS/Windows due to @@ -63,6 +79,7 @@ DOCKER_TOOLS = docker run \ -v $${HOME}/.cache/go-build:/tmp/build/.cache \ -v $${HOME}/go/pkg/mod:/tmp/build/.modcache \ -v $${HOME}/.cache/golangci-lint:/root/.cache/golangci-lint \ + $(DOCKER_GIT_MOUNTS) \ -v $$(pwd):/build taproot-assets-tools else # Local mode: Docker named volumes for fast macOS/Windows performance. @@ -71,6 +88,7 @@ DOCKER_TOOLS = docker run \ -v tapd-go-build-cache:/tmp/build/.cache \ -v tapd-go-mod-cache:/tmp/build/.modcache \ -v tapd-go-lint-cache:/root/.cache/golangci-lint \ + $(DOCKER_GIT_MOUNTS) \ -v $$(pwd):/build taproot-assets-tools endif