From 315a5e5355769db1423ab5620d2929e1fb1b0ca4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 17 Mar 2020 21:28:47 -0700 Subject: [PATCH] scripts: add a license header checker. Signed-off-by: David Anderson --- atomicfile/atomicfile.go | 2 +- net/nettest/pipe_test.go | 4 +++ scripts/check_license_headers.sh | 54 ++++++++++++++++++++++++++++++++ wgengine/magicsock/magicsock.go | 2 +- 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100755 scripts/check_license_headers.sh diff --git a/atomicfile/atomicfile.go b/atomicfile/atomicfile.go index dcf3c3235..f2af37182 100644 --- a/atomicfile/atomicfile.go +++ b/atomicfile/atomicfile.go @@ -1,4 +1,4 @@ -// Copyright 2019 Tailscale & AUTHORS. All rights reserved. +// Copyright (c) 2019 Tailscale Inc & AUTHORS All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/net/nettest/pipe_test.go b/net/nettest/pipe_test.go index f40d27c53..72a839d13 100644 --- a/net/nettest/pipe_test.go +++ b/net/nettest/pipe_test.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package nettest import ( diff --git a/scripts/check_license_headers.sh b/scripts/check_license_headers.sh new file mode 100755 index 000000000..29bb2eee5 --- /dev/null +++ b/scripts/check_license_headers.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. +# +# check_license_headers.sh checks that all Go files in the given +# directory tree have a correct-looking Tailscale license header. + +check_file() { + got=$1 + + for year in `seq 2019 2020`; do + want=$(cat <&2 + exit 1 +fi + +fail=0 +for file in $(find $1 -name '*.go'); do + case $file in + $1/tempfork/*) + # Skip, tempfork of third-party code + ;; + $1/wgengine/ifconfig_windows.go) + # WireGuard copyright. + ;; + *) + header="$(head -3 $file)" + if ! check_file "$header"; then + fail=1 + echo "${file#$1/} doesn't have the right copyright header:" + echo "$header" | sed -e 's/^/ /g' + fi + ;; + esac +done + +if [ $fail -ne 0 ]; then + exit 1 +fi diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index e8a2039c7..8e55e5b91 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -1,4 +1,4 @@ -// Copyright 2019 Tailscale & AUTHORS. All rights reserved. +// Copyright (c) 2019 Tailscale Inc & AUTHORS All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.