2020-03-18 04:28:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2023-01-27 21:37:20 +00:00
|
|
|
# Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
2020-03-18 04:28:47 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2023-01-27 21:36:46 +00:00
|
|
|
want=$(cat <<EOF
|
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-03-18 04:28:47 +00:00
|
|
|
EOF
|
2023-01-27 21:36:46 +00:00
|
|
|
)
|
|
|
|
if [ "$got" = "$want" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
2020-03-18 04:28:47 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# != 1 ]; then
|
|
|
|
echo "Usage: $0 rootdir" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
fail=0
|
2023-11-28 18:15:19 +00:00
|
|
|
for file in $(find $1 \( -name '*.go' -or -name '*.tsx' -or -name '*.ts' -not -name '*.config.ts' \) -not -path '*/.git/*' -not -path '*/node_modules/*'); do
|
2020-03-18 04:28:47 +00:00
|
|
|
case $file in
|
|
|
|
$1/tempfork/*)
|
|
|
|
# Skip, tempfork of third-party code
|
|
|
|
;;
|
2020-04-30 20:20:09 +00:00
|
|
|
$1/wgengine/router/ifconfig_windows.go)
|
2020-03-18 04:28:47 +00:00
|
|
|
# WireGuard copyright.
|
2023-01-18 02:39:49 +00:00
|
|
|
;;
|
|
|
|
$1/cmd/tailscale/cli/authenticode_windows.go)
|
|
|
|
# WireGuard copyright.
|
2021-07-12 20:05:55 +00:00
|
|
|
;;
|
2021-06-27 08:21:53 +00:00
|
|
|
*_string.go)
|
|
|
|
# Generated file from go:generate stringer
|
|
|
|
;;
|
2021-12-03 02:04:48 +00:00
|
|
|
$1/control/controlbase/noiseexplorer_test.go)
|
2021-06-27 08:21:53 +00:00
|
|
|
# Noiseexplorer.com copyright.
|
|
|
|
;;
|
2022-07-27 22:03:44 +00:00
|
|
|
*/zsyscall_windows.go)
|
|
|
|
# Generated syscall wrappers
|
|
|
|
;;
|
2020-03-18 04:28:47 +00:00
|
|
|
*)
|
2023-01-27 21:36:46 +00:00
|
|
|
header="$(head -2 $file)"
|
2020-03-18 04:28:47 +00:00
|
|
|
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
|