From 1c8262be12c120b43ed18e83321d47e1bd449ea0 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Wed, 13 Apr 2016 16:06:32 +0200 Subject: [PATCH] Add script to check for missing license headers Also adds a `check_license` target to the Makefile to run the script --- Makefile | 6 +++++- scripts/check_license.sh | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/check_license.sh diff --git a/Makefile b/Makefile index 5979b3577..5b02d736b 100644 --- a/Makefile +++ b/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 diff --git a/scripts/check_license.sh b/scripts/check_license.sh new file mode 100755 index 000000000..d3882c6b6 --- /dev/null +++ b/scripts/check_license.sh @@ -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