|
| 1 | +#!/bin/bash -e |
| 2 | + |
| 3 | +TEST=$1 |
| 4 | +set -o pipefail |
| 5 | +cd "$(dirname "$0")"/.. |
| 6 | + |
| 7 | +############################################################################# |
| 8 | +## © Copyright CERN 2018. All rights not expressly granted are reserved. ## |
| 9 | +## Author: Gian.Michele.Innocenti@cern.ch ## |
| 10 | +## This program is free software: you can redistribute it and/or modify it ## |
| 11 | +## under the terms of the GNU General Public License as published by the ## |
| 12 | +## Free Software Foundation, either version 3 of the License, or (at your ## |
| 13 | +## option) any later version. This program is distributed in the hope that ## |
| 14 | +## it will be useful, but WITHOUT ANY WARRANTY; without even the implied ## |
| 15 | +## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ## |
| 16 | +## See the GNU General Public License for more details. ## |
| 17 | +## You should have received a copy of the GNU General Public License ## |
| 18 | +## along with this program. if not, see <https://www.gnu.org/licenses/>. ## |
| 19 | +############################################################################# |
| 20 | + |
| 21 | +function check_copyright() { |
| 22 | + local COPYRIGHT="$(cat <<'EOF' |
| 23 | +############################################################################# |
| 24 | +## © Copyright CERN 2018. All rights not expressly granted are reserved. ## |
| 25 | +## Author: Gian.Michele.Innocenti@cern.ch ## |
| 26 | +## This program is free software: you can redistribute it and/or modify it ## |
| 27 | +## under the terms of the GNU General Public License as published by the ## |
| 28 | +## Free Software Foundation, either version 3 of the License, or (at your ## |
| 29 | +## option) any later version. This program is distributed in the hope that ## |
| 30 | +## it will be useful, but WITHOUT ANY WARRANTY; without even the implied ## |
| 31 | +## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ## |
| 32 | +## See the GNU General Public License for more details. ## |
| 33 | +## You should have received a copy of the GNU General Public License ## |
| 34 | +## along with this program. if not, see <https://www.gnu.org/licenses/>. ## |
| 35 | +############################################################################# |
| 36 | +EOF |
| 37 | +)" |
| 38 | + local COPYRIGHT_LINES=$(echo "$COPYRIGHT" | wc -l) |
| 39 | + [[ "$(head -n$COPYRIGHT_LINES "$1")" == "$COPYRIGHT" ]] || { printf "$1: missing or malformed copyright notice\n"; return 1; } |
| 40 | + return 0 |
| 41 | +} |
| 42 | + |
| 43 | + |
| 44 | +FILES_CHANGED="$1" |
| 45 | + |
| 46 | +ERR=0 |
| 47 | + |
| 48 | +# Find only python files |
| 49 | + |
| 50 | +echo "$FILES_CHANGED" |
| 51 | + |
| 52 | +for PY in $FILES_CHANGED; do |
| 53 | + check_copyright "$PY" || ERR=1 |
| 54 | +done |
| 55 | +exit $ERR |
0 commit comments