mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
Meta: Make copyright header check more strict
This commit is contained in:
parent
45f97e577e
commit
da72c6987f
1 changed files with 15 additions and 8 deletions
|
@ -3,11 +3,16 @@
|
||||||
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||||
cd "$script_path/.." || exit 1
|
cd "$script_path/.." || exit 1
|
||||||
|
|
||||||
# We simply check if the file starts with:
|
# Ensure copyright headers match this format:
|
||||||
# /*
|
# /*
|
||||||
# * Copyright
|
# * Copyright (c) YYYY(-YYYY), Whatever
|
||||||
LICENSE_HEADER_PATTERN=$'^([^\n]*\n)?/\*\n \* Copyright'
|
# * ... more of these ...
|
||||||
MISSING_LICENSE_HEADER_ERRORS=()
|
# *
|
||||||
|
# * SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
# */
|
||||||
|
GOOD_LICENSE_HEADER_PATTERN=$'^/\*\n( \* Copyright \(c\) [0-9]{4}(-[0-9]{4})?, .*\n)+ \*\n \* SPDX-License-Identifier: BSD-2-Clause\n \*/\n'
|
||||||
|
BAD_LICENSE_HEADER_ERRORS=()
|
||||||
|
LICENSE_HEADER_CHECK_EXCUDES=(AK/Checked.h AK/Function.h Userland/Libraries/LibC/elf.h)
|
||||||
|
|
||||||
# We check that "#pragma once" is present
|
# We check that "#pragma once" is present
|
||||||
PRAGMA_ONCE_PATTERN='#pragma once'
|
PRAGMA_ONCE_PATTERN='#pragma once'
|
||||||
|
@ -23,8 +28,10 @@ LIBM_MATH_H_INCLUDE_ERRORS=()
|
||||||
|
|
||||||
while IFS= read -r f; do
|
while IFS= read -r f; do
|
||||||
file_content="$(< "$f")"
|
file_content="$(< "$f")"
|
||||||
if [[ ! "$file_content" =~ $LICENSE_HEADER_PATTERN ]]; then
|
if [[ ! "${LICENSE_HEADER_CHECK_EXCUDES[*]} " =~ $f ]]; then
|
||||||
MISSING_LICENSE_HEADER_ERRORS+=("$f")
|
if [[ ! "$file_content" =~ $GOOD_LICENSE_HEADER_PATTERN ]]; then
|
||||||
|
BAD_LICENSE_HEADER_ERRORS+=("$f")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ "$file_content" =~ $LIBM_MATH_H_INCLUDE_PATTERN ]]; then
|
if [[ "$file_content" =~ $LIBM_MATH_H_INCLUDE_PATTERN ]]; then
|
||||||
LIBM_MATH_H_INCLUDE_ERRORS+=("$f")
|
LIBM_MATH_H_INCLUDE_ERRORS+=("$f")
|
||||||
|
@ -44,8 +51,8 @@ done < <(git ls-files -- \
|
||||||
)
|
)
|
||||||
|
|
||||||
exit_status=0
|
exit_status=0
|
||||||
if (( ${#MISSING_LICENSE_HEADER_ERRORS[@]} )); then
|
if (( ${#BAD_LICENSE_HEADER_ERRORS[@]} )); then
|
||||||
echo "Files missing license headers: ${MISSING_LICENSE_HEADER_ERRORS[*]}"
|
echo "Files with missing or incorrect license header: ${BAD_LICENSE_HEADER_ERRORS[*]}"
|
||||||
exit_status=1
|
exit_status=1
|
||||||
fi
|
fi
|
||||||
if (( ${#MISSING_PRAGMA_ONCE_ERRORS[@]} )); then
|
if (( ${#MISSING_PRAGMA_ONCE_ERRORS[@]} )); then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue