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:
Jonathan Boulle 2016-04-13 16:06:32 +02:00
parent 322ad49b01
commit 1c8262be12
2 changed files with 15 additions and 1 deletions

View file

@ -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
View 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