mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Add script to check for missing license headers
Also adds a `check_license` target to the Makefile to run the script
This commit is contained in:
parent
322ad49b01
commit
1c8262be12
6
Makefile
6
Makefile
|
@ -25,6 +25,10 @@ style:
|
|||
@echo ">> checking code style"
|
||||
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
|
||||
|
||||
check_license:
|
||||
@echo ">> checking license header"
|
||||
@./scripts/check_license.sh
|
||||
|
||||
test:
|
||||
@echo ">> running tests"
|
||||
@$(GO) test -short $(pkgs)
|
||||
|
@ -54,5 +58,5 @@ assets:
|
|||
@go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
|
||||
|
||||
|
||||
.PHONY: all style format build test vet docker assets tarballs
|
||||
.PHONY: all style check_license format build test vet docker assets tarballs
|
||||
|
||||
|
|
10
scripts/check_license.sh
Executable file
10
scripts/check_license.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
licRes=$(
|
||||
for file in $(find . -type f -iname '*.go' ! -path './vendor/*'); do
|
||||
head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" || echo -e " ${file}"
|
||||
done;)
|
||||
if [ -n "${licRes}" ]; then
|
||||
echo -e "license header checking failed:\n${licRes}"
|
||||
exit 255
|
||||
fi
|
Loading…
Reference in a new issue