summaryrefslogtreecommitdiff
path: root/Meta/check-license-headers.sh
blob: 60cd03151ea3180ef15a166aed40fca4990939b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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