[ARVADOS-DEV] updated: 19e300ed030f7fa1cc50913ecb4d42e50f397ed7
Git user
git at public.curoverse.com
Wed May 23 17:18:08 EDT 2018
Summary of changes:
git/hooks/check-copyright-headers.sh | 67 ++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100755 git/hooks/check-copyright-headers.sh
via 19e300ed030f7fa1cc50913ecb4d42e50f397ed7 (commit)
from a65ef5beec96779918cc2a0a26dd158d873ac2ee (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 19e300ed030f7fa1cc50913ecb4d42e50f397ed7
Author: Ward Vandewege <wvandewege at veritasgenetics.com>
Date: Wed May 23 17:17:15 2018 -0400
Add a git hook to ensure that all commits adhere to the copyright header
convention for the Arvados project.
No issue #
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <wvandewege at veritasgenetics.com>
diff --git a/git/hooks/check-copyright-headers.sh b/git/hooks/check-copyright-headers.sh
new file mode 100755
index 0000000..f219532
--- /dev/null
+++ b/git/hooks/check-copyright-headers.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+# This script is intended to be run as a git update hook. It ensures that all
+# commits adhere to the copyright header convention for the Arvados project,
+# which is documented at
+#
+# https://dev.arvados.org/projects/arvados/wiki/Coding_Standards#Copyright-headers
+
+REFNAME=$1
+OLDREV=$2
+NEWREV=$3
+
+EXITCODE=0
+
+# Load the .licenseignore file
+LICENSEIGNORE=`mktemp`
+git show ${NEWREV}:.licenseignore > "${LICENSEIGNORE}" 2>/dev/null
+if [[ "$?" != "0" ]]; then
+ # e.g., .licenseignore does not exist
+ ignores=()
+else
+ IFS=$'\n' read -a ignores -r -d $'\000' < "$LICENSEIGNORE" || true
+fi
+rm -f $LICENSEIGNORE
+
+oldIFS="$IFS"
+IFS=$'\n'
+for rev in $(git rev-list --objects $2..$3 | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'); do
+
+ IFS="$oldIFS" read -r -a array <<<"$rev"
+ sha=${array[0]}
+ fnm=${array[2]}
+
+ # Make sure to skip files that match patterns in .licenseignore
+ ignore=
+ for pattern in "${ignores[@]}"; do
+ if [[ ${fnm} == ${pattern} ]]; then
+ ignore=1
+ fi
+ done
+ if [[ ${ignore} = 1 ]]; then continue; fi
+
+ HEADER=`git show ${sha} | head -n20 | egrep -A3 -B1 'Copyright.*Arvados'`
+
+ if [[ ! "$HEADER" =~ "SPDX-License-Identifier:" ]]; then
+ if [[ "$EXITCODE" == "0" ]]; then
+ echo
+ echo "ERROR"
+ echo
+ fi
+ echo "missing or invalid copyright header in file ${fnm}"
+ EXITCODE=1
+ fi
+done
+IFS="$oldIFS"
+
+if [[ "$EXITCODE" != "0" ]]; then
+ echo
+ echo "[POLICY] all files must contain copyright headers, for more information see"
+ echo
+ echo " https://dev.arvados.org/projects/arvados/wiki/Coding_Standards#Copyright-headers"
+ echo
+ exit $EXITCODE
+fi
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list