[ARVADOS] created: 803bf914252a2147d47693684828a22f074243aa
Git user
git at public.curoverse.com
Thu Jun 1 17:44:37 EDT 2017
at 803bf914252a2147d47693684828a22f074243aa (commit)
commit 803bf914252a2147d47693684828a22f074243aa
Author: Tom Clegg <tom at curoverse.com>
Date: Thu Jun 1 14:50:17 2017 -0400
2411: Add build/check-copyright.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>
diff --git a/build/check-copyright-notices b/build/check-copyright-notices
new file mode 100755
index 0000000..c3af420
--- /dev/null
+++ b/build/check-copyright-notices
@@ -0,0 +1,165 @@
+#!/bin/bash
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+set -e
+
+fix=false
+while [[ "${@}" != "" ]]
+do
+ arg=${1}
+ shift
+ case ${arg} in
+ --fix)
+ fix=true
+ ;;
+ --)
+ break
+ ;;
+ esac
+done
+
+fixer() {
+ want="${want}" perl -pi~ -e 'if ($. == 1) { s{^(\#\!.*\n)?}{${1}$ENV{want}\n} }' "${1}"
+}
+
+# echo "gofmt..."
+# if gofmt -l $(ls -1d */ | egrep -v 'vendor|tmp') | egrep .
+# then
+# echo "...gofmt failed."
+# exit 1
+# fi
+
+echo "copyright..."
+result=0
+git ls-files -z ${@} | \
+ while read -rd $'\000' fnm
+ do
+ cs=
+ cc=
+ ce=
+ fixer=
+ if [[ ! -f ${fnm} ]] || [[ -L ${fnm} ]] || [[ ! -s ${fnm} ]]
+ then
+ continue
+ fi
+ case ${fnm} in
+ */runit-docker/* | apps/workbench/app/assets/javascripts/list.js)
+ continue
+ ;;
+ *.gz.report | *agpl-3.0.txt | */LICENSE.txt | *LICENSE-2.0.txt | *by-sa-3.0.txt | *COPYING | */proc_stat | */robots.txt | */README | *.map)
+ continue
+ ;;
+ *Makefile | */Dockerfile.* | */Dockerfile | */MANIFEST.in | */fuse.conf | */gitolite.rc | *.yml.example)
+ fixer=fixer
+ cc="#"
+ ;;
+ *.pl | *.pm | *.PL | *.py | sdk/python/bin/arv-* | *.rb | *.rb.example | *.rake | *.ru | sdk/cli/bin/* | *.yaml | *.yml | *.cwl | *.sh | *.service | *.gemspec | */Gemfile | */Rakefile | */run| */run-service | */restart-dns-server | */nodemanager/doc/*.cfg | crunch_scripts/* | build/build.list)
+ fixer=fixer
+ cc="#"
+ ;;
+ *.rst)
+ fixer=fixer
+ cc=".."
+ ce=$'\n'
+ ;;
+ *.erb)
+ fixer=fixer
+ cs="<%#"
+ cc=""
+ ce=" %>"
+ ;;
+ *.liquid)
+ fixer=fixer
+ cs=$'{% comment %}\n'
+ cc=
+ ce=$'\n%{% endcomment %}'
+ ;;
+ *.textile)
+ fixer=fixer
+ cs="###."
+ cc="...."
+ ce=
+ ;;
+ *.css)
+ fixer=fixer
+ cs="/*"
+ cc=""
+ ce=" */"
+ ;;
+ *.go | *.scss | *.java | *.js | *.coffee)
+ fixer=fixer
+ cc="//"
+ ;;
+ *.sql)
+ fixer=fixer
+ cc="--"
+ ;;
+ *.html | *.svg)
+ fixer=fixer
+ cs="<!-- "
+ cc=
+ ce=" -->"
+ ;;
+ *.ico | *.png | *.jpg | *.gif | doc/fonts/* | *.json | */.gitignore | */.gitkeep | */.gitstub | *.gz | *.log | *.tar | *.lock | */script/rails | */docker_image)
+ continue
+ ;;
+ *)
+ cc="#"
+ hashbang=$(head -n1 ${fnm})
+ if [[ ${hashbang} = "#!/bin/sh" ]] || [[ ${hashbang} = "#!/bin/bash" ]]
+ then
+ fixer=fixer
+ fi
+ ;;
+ esac
+ wantGPL="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
+${cc}
+${cc}${cc:+ }SPDX-License-Identifier: AGPL-3.0${ce}
+"
+ wantApache="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
+${cc}
+${cc}${cc:+ }SPDX-License-Identifier: Apache-2.0${ce}
+"
+ wantBYSA="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
+${cc}
+${cc}${cc:+ }SPDX-License-Identifier: CC-BY-SA-3.0${ce}
+"
+ stmt=$(head "$fnm" | egrep -A2 'Copyright.*Arvados' || true)
+ case ${fnm} in
+ build/* | lib/* | tools/* | apps/* | services/*)
+ want=${wantGPL}
+ ;;
+ backports/* | sdk/*)
+ want=${wantApache}
+ ;;
+ doc/*)
+ want=${wantBYSA}
+ ;;
+ *)
+ want=
+ ;;
+ esac
+ case "$stmt" in
+ "$wantGPL")
+ ;;
+ "$wantApache")
+ ;;
+ "$wantBYSA")
+ ;;
+ *)
+ if [[ -z ${stmt} ]] && [[ -n ${want} ]] && [[ $fix = true ]] && [[ $fixer != "" ]]
+ then
+ ${fixer} ${fnm}
+ else
+ echo "$fnm: missing copyright notice: found '${stmt}'"
+ result=1
+ fi
+ ;;
+ esac
+ done
+if [[ $result != 0 ]]
+then
+ exit $result
+fi
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list