Meta: Add script to enforce license headers & run it on Travis

This commit is contained in:
Linus Groh 2020-05-09 18:15:45 +01:00 committed by Andreas Kling
parent 60024ab574
commit 358694567f
4 changed files with 31 additions and 1 deletions

View file

@ -34,6 +34,7 @@ script:
- cd ../Kernel
- ./makeall.sh
- ../Meta/lint-shell-scripts.sh
- ../Meta/check-license-headers.sh
- ../Meta/Lagom/build-js.sh
- cd ../Libraries/LibJS/Tests
- ./run-tests

View file

@ -1,4 +1,3 @@
/*
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
* All rights reserved.

30
Meta/check-license-headers.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "$script_path/.." || exit 1
# We simply check if the file starts with:
# /*
# * Copyright
PATTERN=$'^/\*\n \* Copyright'
ERRORS=()
while IFS= read -r f; do
if [[ ! $(cat "$f") =~ $PATTERN ]]; then
ERRORS+=("$f")
fi
done < <(git ls-files -- \
'*.cpp' \
'*.h' \
':!:Tests' \
':!:Base' \
':!:Kernel/FileSystem/ext2_fs.h' \
':!:Libraries/LibC/getopt.cpp' \
':!:Libraries/LibCore/puff.h' \
':!:Libraries/LibELF/exec_elf.h' \
)
if (( ${#ERRORS[@]} )); then
echo "Files missing license headers: ${ERRORS[*]}"
exit 1
fi