mirror of
https://github.com/prometheus/prometheus.git
synced 2025-11-30 23:21:02 +01:00
Makefile.common: Use git ls-files instead of find for license check and style check (#17557)
Also improve find fallback to use -prune for better performance. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This commit is contained in:
parent
1174b0ce4f
commit
61f64a4cb1
@ -112,7 +112,7 @@ common-all: precheck style check_license lint yamllint unused build test
|
|||||||
.PHONY: common-style
|
.PHONY: common-style
|
||||||
common-style:
|
common-style:
|
||||||
@echo ">> checking code style"
|
@echo ">> checking code style"
|
||||||
@fmtRes=$$($(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \
|
@fmtRes=$$($(GOFMT) -d $$(git ls-files '*.go' ':!:vendor/*' || find . -path ./vendor -prune -o -name '*.go' -print)); \
|
||||||
if [ -n "$${fmtRes}" ]; then \
|
if [ -n "$${fmtRes}" ]; then \
|
||||||
echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \
|
echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \
|
||||||
echo "Please ensure you are using $$($(GO) version) for formatting code."; \
|
echo "Please ensure you are using $$($(GO) version) for formatting code."; \
|
||||||
@ -122,7 +122,7 @@ common-style:
|
|||||||
.PHONY: common-check_license
|
.PHONY: common-check_license
|
||||||
common-check_license:
|
common-check_license:
|
||||||
@echo ">> checking license header"
|
@echo ">> checking license header"
|
||||||
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
|
@licRes=$$(for file in $$(git ls-files '*.go' ':!:vendor/*' || find . -path ./vendor -prune -o -type f -iname '*.go' -print) ; do \
|
||||||
awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
|
awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
|
||||||
done); \
|
done); \
|
||||||
if [ -n "$${licRes}" ]; then \
|
if [ -n "$${licRes}" ]; then \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user