diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bda55d38f..d01c57a3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,5 +33,6 @@ repos: - id: copyright-headers name: copyright-headers language: script + types_or: [python, shell, yaml, dockerfile] entry: bin/linters/check_headers_exist.sh diff --git a/README.md b/README.md index 2b4573e9d..a9938270c 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ setfacl -R -m d:g::rwX /gae/pixl_dev ### 1. Choose deployment environment -This is one of dev|test|staging|prod and referred to as `` in the docs. +This is one of `dev|test|staging|prod` and referred to as `` in the docs. ### 2. Initialise environment configuration diff --git a/bin/linters/check_headers_exist.sh b/bin/linters/check_headers_exist.sh index 2542f211f..d7c1e6fa8 100755 --- a/bin/linters/check_headers_exist.sh +++ b/bin/linters/check_headers_exist.sh @@ -12,15 +12,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +set -euo pipefail -for ext in ".yml" ".yaml" ".sh" "Dockerfile" ".py" -do - # shellcheck disable=SC2044 - for path in $(find . -name "*$ext") - do - if ! grep -q "Copyright" "$path"; then - echo -e "\n\e[31m»»» ⚠️ No copyright/license header in $path" - exit 1 - fi - done || exit 1 +for f in "$@"; do + if ! grep -q '#.*Copyright.*University College London Hospitals NHS Foundation Trust' "$f"; then + echo "No copyright notice found in $f" + exit 1 + fi + if ! grep -q '#.*Licensed under the Apache License, Version 2.0' "$f"; then + echo "No licence notice found in $f" + exit 1 + fi done