Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Commit f4d34d2

Browse files
committed
Makefile: ensure that diff.noprefix is set to false when linting
After running the linter, restore local settings to original variable or just unset it. This is to avoid people hitting golangci/golangci-lint#948, as it seems the note in Makefile is not good enough. Signed-off-by: Mateusz Gozdek <[email protected]>
1 parent 833ee49 commit f4d34d2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ build-slim:
6060
test: run-unit-tests
6161

6262
.PHONY: lint
63+
lint: diffnoprefix := $(shell sh -c "git config --get --show-origin diff.noprefix | awk '/file:\.git\/config\s+\S+/ {print \$$2}'")
6364
lint: build-slim build-test
64-
# Note: Make sure that you run `git config diff.noprefix false` in this repo
65-
# See this issue for more details: https://github.com/golangci/golangci-lint/issues/948
65+
# To workaround: https://github.com/golangci/golangci-lint/issues/948
66+
git config --replace-all diff.noprefix false
6667
golangci-lint run --enable-all --disable=godox,gochecknoglobals,goerr113 --max-same-issues=0 --max-issues-per-linter=0 --build-tags $(ALL_BUILD_TAGS) --new-from-rev=$$(git merge-base $$(cat .git/resource/base_sha 2>/dev/null || echo "origin/master") HEAD) --modules-download-mode=$(MOD) --timeout=5m --exclude-use-default=false ./...
68+
if [ -z "$(diffnoprefix)" ]; then git config --unset diff.noprefix; else git config --replace-all diff.noprefix $(diffnoprefix); fi
6769

6870
.PHONY: lint-docker
6971
lint-docker:

0 commit comments

Comments
 (0)