From 80d42931cbf93be24f8ef73b2325a65b940ccfe8 Mon Sep 17 00:00:00 2001 From: Nicholas J Date: Sun, 15 Oct 2017 23:47:22 -0400 Subject: [PATCH] Feature: Add check_license.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is currently no automated script to ensure all source files have a license header, fortunately Prometheus already has a script provided by @jonboulle and I have simply copied that script and applied it to this code base. Example output: ``` github.com/prometheus/common on  feat-add-license-check [+] ➜ ./scripts/check_license.sh -e license header checking failed: -e ./route/route.go -e ./route/route_test.go ``` All credit to @jonboulle for the initial script. --- scripts/check_license.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 scripts/check_license.sh diff --git a/scripts/check_license.sh b/scripts/check_license.sh new file mode 100755 index 000000000..c88d3cacb --- /dev/null +++ b/scripts/check_license.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +licRes=$( +for file in $(find . -type f -iname '*.go' ! -path './internal/*'); 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