Add script to check for missing license headers

Also adds a `check_license` target to the Makefile to run the script
pull/1554/head
Jonathan Boulle 10 years ago
parent 322ad49b01
commit 1c8262be12
  1. 6
      Makefile
  2. 10
      scripts/check_license.sh

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

@ -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…
Cancel
Save