2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # This script is intended to be run as a git update hook. It ensures that all
7 # commits adhere to the copyright header convention for the Arvados project,
8 # which is documented at
10 # https://dev.arvados.org/projects/arvados/wiki/Coding_Standards#Copyright-headers
18 # Load the .licenseignore file
19 LICENSEIGNORE=`mktemp`
20 git show ${NEWREV}:.licenseignore > "${LICENSEIGNORE}" 2>/dev/null
21 if [[ "$?" != "0" ]]; then
22 # e.g., .licenseignore does not exist
25 IFS=$'\n' read -a ignores -r -d $'\000' < "$LICENSEIGNORE" || true
31 for rev in $(git rev-list --objects $2..$3 | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'); do
33 IFS="$oldIFS" read -r -a array <<<"$rev"
37 # Make sure to skip files that match patterns in .licenseignore
39 for pattern in "${ignores[@]}"; do
40 if [[ ${fnm} == ${pattern} ]]; then
44 if [[ ${ignore} = 1 ]]; then continue; fi
46 HEADER=`git show ${sha} | head -n20 | egrep -A3 -B1 'Copyright.*Arvados'`
48 if [[ ! "$HEADER" =~ "SPDX-License-Identifier:" ]]; then
49 if [[ "$EXITCODE" == "0" ]]; then
54 echo "missing or invalid copyright header in file ${fnm}"
60 if [[ "$EXITCODE" != "0" ]]; then
62 echo "[POLICY] all files must contain copyright headers, for more information see"
64 echo " https://dev.arvados.org/projects/arvados/wiki/Coding_Standards#Copyright-headers"